Skip to content

fix(pipelines): show Pipelines API error messages instead of "Unknown error" (CDP-7304) - #268

Open
senechko wants to merge 1 commit into
mainfrom
cdp-7304-pipelines-error-messages
Open

senechko wants to merge 1 commit into
mainfrom
cdp-7304-pipelines-error-messages

Conversation

@senechko

@senechko senechko commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Fixes CDP-7304.

Every error from the Pipelines API showed up as "Unknown error", because CustomerIORequestError.composeMessage only read the Track and App API error formats. It now also reads the Pipelines API formats, in this order:

  1. code and message: {"success":false,"code":"internal_error","message":"The request failed. Retry it."} gives internal_error: The request failed. Retry it.
  2. Strict-mode errors[], with each item's field and batch index: authorization: must provide valid credentials, or for a batch a list such as batch[0].event: must provide value for required field.
  3. A non-JSON text body.
  4. The status code: 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.ts expected "Unknown error" for a body the SDK doesn't recognise. They now expect the status message.

Left for a separate change: request.ts still throws Unable to parse JSON for a non-JSON error body (such as fasthttp's plain-text 400, CDP-7266) before composeMessage sees it. Routing those through CustomerIORequestError would also make non-JSON 5xx bodies retryable.

Testing

  • New test/utils.ts: each Pipelines error body through PipelinesClient (sent as text/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.

… 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
@senechko
senechko requested a review from a team as a code owner November 20, 2026 23:48

This branch has not been deployed

No deployments
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.

1 participant