Repository navigation
fix(gainsight_px): retry lookup timeouts instead of aborting as 400 - #5761
Conversation
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]>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
There was a problem hiding this comment.
🟢 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
processedResponsefor 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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
This reverts commit 9b97fae.
…es aborting" This reverts commit 22fbaaf.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
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]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
There was a problem hiding this comment.
🔵 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
…guard Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
lvrach
left a comment
There was a problem hiding this comment.
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
-
An unexpected 2xx is thrown with its own status (
util.js,handleErrorResponse). Failing input:PUT /accounts/{id}returns 200 where 204 is expected,POST /accountsreturns 200 where 201 is expected, orGETreturns 204. The NetworkError carries that 2xx into a router output with no request. rudder-server treats any 2xx as success (router/misc.goisSuccessStatus,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;. -
Empty-body 400 on the account update continues silently (
transform.js:144-157,newGroupResponseBuilder, thelimitAPIForGrouppath). Failing input:PUT /accounts/{id}returns 400 with an empty body.handleErrorResponsereturnserr: ''.err === nullandif (err)both read false, so the builder emitsPUT /users/{id} {accountId}for an account it did not update. Before this PR, it aborted with 400. The other call sites checksuccessand still abort. Fix:if (!updateSuccess)at line 155, orerr: errMessage || \status ${status}`inhandleErrorResponse. Next to it, two older bugs: theerr === nullcreate branch was dead before and after this PR, and line 149 readserror, whichcreateAccount` does not return. -
The unit tests do not prove the 400-to-500 change (
util.test.ts). Each mock returns only{ processedResponse }. The old code readshttpResponse, 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.nodeSysErrorToStatusmapsENOTFOUND,EPIPE,EHOSTUNREACHand 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: whentransformStatusCodeis set, the step returns early. It ignoresitems,category,expectedOutputsandexpectedProxyRequests, and it does not match output job IDs to the seeded jobs. Reject those combinations the way the runner rejectsitems: []. To show the cause on a mismatch, printo.errorando.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.




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 witherror 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:
handleHttpRequestalready returns aprocessedResponse. Its status comes from the sharedprocessAxiosResponse→nodeSysErrorToStatusmapping, which gives 500 forECONNABORTED,ETIMEDOUTandECONNRESET. gainsight_px was ignoring it and parsing the raw axios error itself. All three calls (the user/account existence check,createAccountandupdateAccount) now readprocessedResponse.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 ?
error while fetching user:… "[ECONNABORTED] :: Connection aborted"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.
err: '', and the identify path'sif (err)reads that as success, so the account update is skipped silently.Any new dependencies introduced with this change?
N/A
Any new generic utility introduced or modified. Please explain the changes.
expectedFailuregainstransformStatusCode. Pipeline steps used to fail on any non-2xx/routerTransformoutput, so the harness couldn't say "this transform must fail with status X". The new field lets it, and it is documented intest/integrations/live/README.md.expectedFailure, following the harness's "one field for every kind of failure" rule.runPipelineStep.test.ts.processAxiosResponse.Any technical or performance related pointers to consider with the change?
drip,mailchimpandyahoo_dsphave 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.err === null/if (err)"not found" contract intransform.js(identify/group) is left untouched. Replacing it with an explicit not-found flag would also close the first known finding above.REQUEST_TIMEOUT_IN_MS=1. Before the fix it returned400 "error while fetching user: "; after the fix it returns500. The control run with the default timeout returned200both times.util.test.ts): a timeout gives a retryable 500, and a 404 still means "user not found".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-uniquetitleis read back from Gainsight. This uses the standardtitlefield because thegainsight_px_audiencespec 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 expectsexpectedFailure: { transformStatusCode: 500 }. Run against the unfixedutil.js, this scenario fails (gets 400); with the fix it passes.LIVE_SECRET_GAINSIGHT_PXneedsconfig.productTagKey(the sandbox product key) added, because PX rejects any otherpropertyKeysvalue 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".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