Skip to content

fix(gainsight_px): retry lookup timeouts instead of aborting as 400 - #5761

Merged
shekhar-rudder merged 14 commits into
developfrom
fix/gainsight-px-timeout-retryable
Nov 4, 2026
Merged

shekhar-rudder merged 14 commits into
developfrom
fix/gainsight-px-timeout-retryable

Conversation

@shekhar-rudder

@shekhar-rudder shekhar-rudder commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

What are the changes introduced in this PR?

Gainsight PX look-ups that time out or get no HTTP response are now retried as 500s. Before this change they were aborted as permanent 400s.

The router transform makes a GET call before every identify and group event to check whether the user or account already exists. When that call failed, handleErrorResponse (gainsight_px/util.js) used the provider's status code only if the failed response had a body. A timeout or connection reset has no response, so it fell back to a hard-coded 400, and the event was aborted with error while fetching user: (nothing after the colon) instead of being retried.

In one recent incident, the Gainsight API was slow and returning 500s for about an hour during a daily full sync. The look-ups that hit our 60s request timeout were aborted, and about 800 events were permanently lost from a single destination in roughly 15 minutes.

Fix: handleHttpRequest already returns a processedResponse. Its status comes from the shared processAxiosResponse → nodeSysErrorToStatus mapping, which gives 500 for ECONNABORTED, ETIMEDOUT and ECONNRESET. gainsight_px was ignoring it and parsing the raw axios error itself. All three calls (the user/account existence check, createAccount and updateAccount) now read processedResponse.

What is the related Linear task?

N/A. No ticket has been filed yet.

Please explain the objectives of your changes below

Any changes to existing capabilities/behaviour, mention the reason & what are the changes ?

failure on the GET/POST/PUT before after
timeout / connection reset (no response) 400, aborted, error while fetching user: 500, retried, … "[ECONNABORTED] :: Connection aborted"
5xx with an empty body 400, aborted the real status, retried
DNS failure / unknown socket error 400 400 (shared mapping, unchanged)
4xx/5xx with a body, expected 404/400 with a body unchanged unchanged

Known review findings

The review raised two edge cases that change behaviour. They are deliberately not handled here: neither has been reproduced, and in the last 30 days Gainsight PX returned only 200/404/429/500 to the GET look-ups, with no account create or update calls at all.

  • Empty-body expected status (for example an empty 400 on account update). Before, this aborted as 400. Now it returns err: '', and the identify path's if (err) reads that as success, so the account update is skipped silently.
  • Unexpected 2xx (for example 200 where 201 was expected). Before, this aborted as 400. Now it throws with status 200. rudder-server treats a status-200 output as a successful transform, fails to parse the missing request (599), and retries until the job expires.

Any new dependencies introduced with this change?

N/A

Any new generic utility introduced or modified. Please explain the changes.

  • Live harness: expectedFailure gains transformStatusCode. Pipeline steps used to fail on any non-2xx /routerTransform output, so the harness couldn't say "this transform must fail with status X". The new field lets it, and it is documented in test/integrations/live/README.md.
    • The field sits inside expectedFailure, following the harness's "one field for every kind of failure" rule.
    • The failure diff contains only status codes, so router outputs (which carry credentials) never reach the jest output.
    • Unit tests are in runPipelineStep.test.ts.
  • The fix itself reuses the existing processAxiosResponse.

Any technical or performance related pointers to consider with the change?

  • drip, mailchimp and yahoo_dsp have the same "parse the raw error, default to 400" pattern on transform-time look-ups. They are left for a follow-up so this change stays limited to one destination.
  • The err === null / if (err) "not found" contract in transform.js (identify/group) is left untouched. Replacing it with an explicit not-found flag would also close the first known finding above.
  • Testing:
    • Live, against the real Gainsight PX API with the e2e sandbox key. I ran the actual router transform with REQUEST_TIMEOUT_IN_MS=1. Before the fix it returned 400 "error while fetching user: "; after the fix it returns 500. The control run with the default timeout returned 200 both times.
    • Unit tests (util.test.ts): a timeout gives a retryable 500, and a 404 still means "user not found".
    • Live spec (test/integrations/destinations/gainsight_px/live.ts, picked up by the live CI matrix automatically):
      • gainsight-px-identify-existing-user: an identify for the sandbox user goes through lookup → PUT /users/{id}, and the run-unique title is read back from Gainsight. This uses the standard title field because the gainsight_px_audience spec writes custom attributes on the same user.
      • gainsight-px-identify-lookup-timeout: a setup step adds a URL-scoped axios interceptor (timeout: 1) on PX requests, removed at scenario cleanup. The step expects expectedFailure: { transformStatusCode: 500 }. Run against the unfixed util.js, this scenario fails (gets 400); with the fix it passes.
    • Vault: LIVE_SECRET_GAINSIGHT_PX needs config.productTagKey (the sandbox product key) added, because PX rejects any other propertyKeys value with a 400. I tested locally with the key read from the sandbox user. Without it, both scenarios fail in CI with "product tag key is required".
    • Existing suites: all gainsight_px unit and component tests pass.

Developer checklist

  • My code follows the style guidelines of this project

  • No breaking changes are being introduced.

  • All related docs linked with the PR?

  • All changes manually tested?

  • Any documentation changes needed with this change?

  • Is the PR limited to 10 file changes?

  • Is the PR limited to one linear task?

  • Are relevant unit and component test-cases added in new readability format?

Reviewer checklist

  • Is the type of change in the PR title appropriate as per the changes?

  • Verified that there are no credentials or confidential data exposed with the changes.

🤖 Generated with Claude Code

shekhar-rudder and others added 5 commits November 2, 2026 15:36
handleErrorResponse defaulted to 400 whenever the failed request had no
response body, so a timed-out or reset existence lookup was aborted
instead of retried. Derive the status with getErrorStatusCode, which
keeps the provider status when there is one and falls back to 500.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Use the status handleHttpRequest already computes via processAxiosResponse
instead of re-deriving it from the raw axios error, so gainsight_px
classifies socket errors the same way as other destinations and keeps the
shared error text.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Drop the raw httpResponse at the three call sites so success and error
paths read one view of the response, and restore the 404 not-found test.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
An empty-body expected status now throws instead of returning an empty
err the identify path reads as success, and an unexpected 2xx keeps
aborting as 400 as before.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 2, 2026 10:17
@shekhar-rudder
shekhar-rudder requested review from a team as code owners November 2, 2026 10:17
@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c8a45858-d5ae-4191-95a7-499b88c416d4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the Gainsight PX HTTP response-handling update.

No open issues 🎉

What changed in this PR

This PR updates Gainsight PX transform-time HTTP handling to use shared response processing, allowing timeouts and connection resets to be retried rather than permanently aborted.

Changes:

  • Uses processedResponse for existence checks and account creation/update calls.
  • Preserves abort behavior for empty-body expected errors and unexpected success statuses.
  • Adds regression tests for timeout retries, missing users, and account error handling.
File Description
src/​v0/​destinations/​gainsight_px/​util.test.js Adds four regression tests covering retry and abort behavior.
src/​v0/​destinations/​gainsight_px/​util.js Uses normalized HTTP responses and preserves retryable failure statuses.

Review effort: Balanced

@codecov

codecov Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.43%. Comparing base (42b4cd1) to head (79b9be8).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #5761      +/-   ##
===========================================
+ Coverage    92.42%   92.43%   +0.01%     
===========================================
  Files          741      741              
  Lines        41050    41055       +5     
  Branches      9558     9646      +88     
===========================================
+ Hits         37940    37950      +10     
+ Misses        2926     2844      -82     
- Partials       184      261      +77     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI balanced review requested due to automatic review settings November 2, 2026 10:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The review reports no active issues with the Gainsight PX request-handling changes.

No open issues 🎉

Review effort: Balanced

shekhar-rudder and others added 2 commits November 2, 2026 16:19
Adds expectedTransformFailure to live pipeline steps so a scenario can
assert the transform itself fails with a given status, and a
gainsight_px live spec: an identify that updates an existing user, and
one whose user lookup is forced to time out and must come back 500.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Declare an expected transform failure as expectedFailure.transform
{ statusCode, errorType? } (one field for every kind of failure), pin
errorType so an unrelated crash cannot pass as the timeout, reject it
alongside items/category/expectedOutputs/expectedProxyRequests, and
document it in the live README.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 2, 2026 10:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The live tests can fail spuriously because concurrent runs share and overwrite one user, while pipeline validation counts outputs rather than verifying that every seeded job has exactly one result.

2 open issues

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 2, 2026 11:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The failure assertion checks counts and statuses without matching metadata job IDs to seeded jobs, allowing duplicate or missing job attribution to pass while bypassing the existing unaccounted-job check.

2 open issues

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 2, 2026 11:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The failure-path assertions can pass without verifying every seeded job’s outcome, and concurrent Gainsight PX test runs can overwrite the same sandbox user and cause spurious failures.

2 open issues

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 2, 2026 11:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Human assessment is needed because the output-count check can accept duplicate job attribution or reject grouped failures, obscuring whether every seeded job received a verdict.

2 open issues

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 2, 2026 11:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Overlapping CI runs can overwrite the shared sandbox user's run-specific title, causing verification failures even when the transform is correct.

2 open issues

Review effort: Balanced

@sonarqubecloud

sonarqubecloud Bot commented Nov 2, 2026

Copy link
Copy Markdown

@lvrach lvrach left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: this review is part of an experiment, the #proj-auto-approve auto-approval process. No human looked at this PR. Auto-approve category: documented bug fix.

Approve. The fix does what the description says. A lookup, create or update that gets no response now throws a retryable 500 from the shared processAxiosResponse mapping. Before, it threw a 400. I traced every response shape through processAxiosResponse. response is always data || '' or a message string, so .externalapierror and JSON.stringify cannot throw. CI is green on 79b9be8, Live Integration Tests included. Three Opus and Codex lanes reviewed the code statically. Nobody ran tests locally.

Should-fix

  1. An unexpected 2xx is thrown with its own status (util.js, handleErrorResponse). Failing input: PUT /accounts/{id} returns 200 where 204 is expected, POST /accounts returns 200 where 201 is expected, or GET returns 204. The NetworkError carries that 2xx into a router output with no request. rudder-server treats any 2xx as success (router/misc.go isSuccessStatus, isJobTerminated). A 201 or 204 output is marked succeeded and nothing is delivered. A 200 output fails to unmarshal and retries as 599 until the job expires. Before this PR, the error was a visible 400 abort. The description lists the 200 case. The silent loss on 201 and 204 is worse. Fix: const errStatus = isHttpStatusSuccess(status) ? 400 : status;.

  2. Empty-body 400 on the account update continues silently (transform.js:144-157, newGroupResponseBuilder, the limitAPIForGroup path). Failing input: PUT /accounts/{id} returns 400 with an empty body. handleErrorResponse returns err: ''. err === null and if (err) both read false, so the builder emits PUT /users/{id} {accountId} for an account it did not update. Before this PR, it aborted with 400. The other call sites check success and still abort. Fix: if (!updateSuccess) at line 155, or err: errMessage || \status ${status}`inhandleErrorResponse. Next to it, two older bugs: the err === nullcreate branch was dead before and after this PR, and line 149 readserror, which createAccount` does not return.

  3. The unit tests do not prove the 400-to-500 change (util.test.ts). Each mock returns only { processedResponse }. The old code reads httpResponse, so it fails every case with a TypeError, the 201 and 404 cases included. Mock both fields from the same raw axios result. The timeout case then fails with 400 on the old code and passes with 500 on the new code. Please also cover the shapes whose behaviour changed: 5xx with an empty body, 400 and 404 with an empty body, and an unexpected 2xx. The live scenario is the real oracle today, so this is test quality, not a gap in the fix.

Nits

  • util.js:8: the comment says no-response failures become retryable. nodeSysErrorToStatus maps ENOTFOUND, EPIPE, EHOSTUNREACH and unknown codes to 400. On create and update, 400 is also the expected status, so a DNS failure now surfaces as a ConfigurationError. Narrow the comment to timeouts and resets.
  • runPipelineStep.ts:94-99: when transformStatusCode is set, the step returns early. It ignores items, category, expectedOutputs and expectedProxyRequests, and it does not match output job IDs to the seeded jobs. Reject those combinations the way the runner rejects items: []. To show the cause on a mismatch, print o.error and o.statTags, as the failed-output branch does. Both are safe to print.
  • live.ts:83-85: the read-back window is about 25-30 s, and the stated lag is up to 25 s. It may flake near the upper bound.

No credential leak found. The new assertion compares status numbers only, fetchUserTitle reports the status only, and scenario cleanup removes the interceptor.

@shekhar-rudder
shekhar-rudder merged commit 8da2fd2 into develop Nov 4, 2026
71 of 73 checks passed
@shekhar-rudder
shekhar-rudder deleted the fix/gainsight-px-timeout-retryable branch November 4, 2026 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants