Skip to content

fix(nodejs-client): parse HTTP errors independently of response format - #43968

Open
huyengiang101086-spec wants to merge 2 commits into
langgenius:mainfrom
huyengiang101086-spec:fix/node-sdk-error-bodies
Open

huyengiang101086-spec wants to merge 2 commits into
langgenius:mainfrom
huyengiang101086-spec:fix/node-sdk-error-bodies

Conversation

@huyengiang101086-spec

Copy link
Copy Markdown
Contributor

Summary

Streaming and binary SDK requests currently decode failed HTTP responses in the requested success format. A 401 JSON response therefore produces a generic authentication message with a Readable body, while bytes/arraybuffer requests lose the structured error body in a Buffer.

Parse non-success responses through the existing JSON/text parser before mapping the HTTP error. Successful stream/binary decoding and retry policy remain unchanged. Real HTTP regressions cover 401 streaming, 422 bytes, 429 arraybuffer, the JSON-mode control, and malformed JSON error text. Request IDs and Retry-After metadata are preserved.

Fixes #43966

Validation

Windows, Node 24.21.0, repository-locked dependencies:

  • Tests-first HTTP integration module: 4 failed, 5 passed on unchanged production; 9 passed with the fix.
  • vp test --coverage from sdks/nodejs-client/: 116 passed.
  • vp check sdks/nodejs-client from the root: format, lint and type checks passed.
  • vp pack from sdks/nodejs-client/: passed.
  • A local HTTP reproduction using the built public ChatClient.createChatMessage now preserves the server message and JSON body in both blocking and streaming modes.
  • git diff --check: passed.

Checklist

  • This change requires a documentation update, included: Dify Document (not required; restores existing error behavior across response modes)
  • I understand that this PR may be closed in case there was no previous discussion or issues.
  • I've verified the change and added or updated tests where meaningful regression risk justifies coverage.
  • I've updated the documentation accordingly. (not required)
  • I ran make lint && make type-check (backend) and vp staged (frontend). (SDK-only; scoped vp check passed instead)

From Codex

@ghfind-review ghfind-review Bot added the review: low ghfind author score; see https://ghfind.com label Oct 13, 2026
@github-actions github-actions Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review: low ghfind author score; see https://ghfind.com size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Node.js SDK loses HTTP error messages for streaming and binary requests

1 participant