fix: fall back to entire response body when 'error' field is missing #1746
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.
Summary
Fixes #1734
When an OpenAI-compatible API returns error information in fields other than
error(e.g.detailormessage), the Node client currently reports422 status code (no body)instead of showing the actual error content. This differs from the Python client, which falls back to the entire response body.Changes
src/core/error.ts: InAPIError.generate(), whenerrorResponse.errorisundefined, fall back toerrorResponseitself (the entire parsed JSON body) instead of passingundefinedto the error constructor. This is a one-line change:?? errorResponse.tests/error.test.ts: Added tests covering:errorfield) — still works as beforedetailfield — now shows the error contentmessagefield — now shows the error content(no body)Before / After
Before: An error response like
{"detail": "422: The model gpt-5-gibberish does not exist."}would produce:After: The same response now produces:
This matches the Python client's behavior of falling back to the full response body when the
errorfield is absent.