Skip to content

fix: fall back to response body when error field is missing#1775

Open
fuleinist wants to merge 1 commit intoopenai:masterfrom
fuleinist:fix/issue-1734
Open

fix: fall back to response body when error field is missing#1775
fuleinist wants to merge 1 commit intoopenai:masterfrom
fuleinist:fix/issue-1734

Conversation

@fuleinist
Copy link

Summary

When an OpenAI-compatible API returns errors in a field other than error (e.g., detail), the Node.js client previously showed (no body). This PR adds a fallback to display the entire response body, matching the Python client behavior.

Changes

  • Modified src/core/error.ts to fall back to the full response body when the error field is missing

Testing

  • Ran existing test suite
  • Verified error messages display correctly for both standard and non-standard error formats

Fixes #1734

Fixes openai#1734

When an OpenAI-compatible API returns errors in a field other than 'error'
(e.g., 'detail'), the Node.js client would show '(no body)'. Now falls back
to displaying the entire response body, matching Python client behavior.
@fuleinist fuleinist requested a review from a team as a code owner March 17, 2026 08:29
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.

The node.js client only reads errors from the "error" field of a response, with no fallback if it doesn't exist

1 participant