Skip to content

fix(errors): surface the JSON error detail in REST error messages - #195

Merged
tomershlasky merged 1 commit into
mainfrom
prompt-too-long-error-handling
Aug 10, 2026
Merged

fix(errors): surface the JSON error detail in REST error messages#195
tomershlasky merged 1 commit into
mainfrom
prompt-too-long-error-handling

Conversation

@tomershlasky

@tomershlasky tomershlasky commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Context

The API is adding server-side prompt validation: a prompt over the model's token limit is rejected with HTTP 400 and a JSON body like {"detail": "Prompt is too long: ..."}. This PR makes that rejection (and any other JSON-detail error) read cleanly in SDK error messages.

Changes

New readErrorBody() helper in shared/request.ts, used by process and all three queue request sites. Before:

Processing failed: 400 - {"detail":"Prompt is too long: 362 tokens (maximum 226, including the end-of-sequence token). Please shorten the prompt."}

After:

Processing failed: 400 - Prompt is too long: 362 tokens (maximum 226, including the end-of-sequence token). Please shorten the prompt.

Non-JSON bodies and JSON without a string detail fall through to the raw text unchanged.

Tests

  • process and queue.submit with a 400 JSON-detail body reject with the parsed message (msw). Full unit suite: 280 passed; biome clean.
  • Note: pnpm typecheck fails on main and on this branch with a pre-existing error in frame-metadata-diagnostics.ts (lookupFrameMetadata missing on RemoteVideoTrack) — unrelated to this change.

@tomershlasky
tomershlasky force-pushed the prompt-too-long-error-handling branch from 4a3e2f9 to 10cd962 Compare August 9, 2026 10:29
@tomershlasky tomershlasky changed the title fix(errors): surface JSON error detail and stop retrying rejected prompts fix(errors): surface the JSON error detail in REST error messages Aug 9, 2026
@pkg-pr-new

pkg-pr-new Bot commented Aug 9, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@decartai/sdk@195

commit: 10cd962

@tomershlasky
tomershlasky merged commit cf5940b into main Aug 10, 2026
5 checks passed
@tomershlasky
tomershlasky deleted the prompt-too-long-error-handling branch August 10, 2026 10:22
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.

2 participants