Repository navigation
Conversation
… error"
CustomerIORequestError only read the Track and App API error formats, so
every Pipelines API error came out as "Unknown error". composeMessage now
also reads, in order: `code` and `message` ({"success":false,...}), the
strict-mode `errors[]` items with their `field` and batch `index`, a
non-JSON text body, and then the status code. The Track and App API
formats are read first, so their messages don't change.
Retries still depend only on the status code. A non-JSON error body is
still rejected earlier by the JSON parse in request.ts, as before.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016cBGtiYPKFEQaiJSf1xwAy
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes CDP-7304.
Every error from the Pipelines API showed up as "Unknown error", because
CustomerIORequestError.composeMessageonly read the Track and App API error formats. It now also reads the Pipelines API formats, in this order:codeandmessage:{"success":false,"code":"internal_error","message":"The request failed. Retry it."}givesinternal_error: The request failed. Retry it.errors[], with each item's field and batch index:authorization: must provide valid credentials, or for a batch a list such asbatch[0].event: must provide value for required field.Request failed with status 500.Track and App API messages are unchanged, since those formats are still read first. Retries depend only on the status code and
Retry-After, never on the message.Two existing tests in
test/request.tsexpected "Unknown error" for a body the SDK doesn't recognise. They now expect the status message.Left for a separate change:
request.tsstill throwsUnable to parse JSONfor a non-JSON error body (such as fasthttp's plain-text 400, CDP-7266) beforecomposeMessagesees it. Routing those throughCustomerIORequestErrorwould also make non-JSON 5xx bodies retryable.Testing
test/utils.ts: each Pipelines error body throughPipelinesClient(sent astext/plain, as the API does today), checking the message, status and number of attempts, plus a regression check on the Track and App formats.npm test: 500 passed, 100% coverage.npm run lint: clean.Found while reviewing customerio/cdp#6527.