Conversation
…tring
OpenAI-compatible providers and gateways do not all send the error body as an
object: some return the message as a plain string, either as the error field
(`{"error": "Gateway failed"}`) or as the whole JSON body. getProviderMessage
required `error.error` to be a record, so those payloads were discarded and the
user only saw the generic SDK text ("HTTP 502: 502 Bad Gateway") instead of the
provider's own explanation - which is the part that says what to fix (model not
found, quota, blocked key, ...).
Accept a string payload as the provider message; the object shape is unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
getProviderMessage()only accepted an object-shaped error payload, so a provideror gateway that sends the message as a plain string was silently dropped:
describeLlmError()prefers this provider text over the SDK's message, so when thepayload is a string the fallback wins and the user is shown the generic
HTTP 502: 502 Bad Gateway- the status survives, but the part that says whatactually went wrong (model not found, quota exhausted, key blocked, IP not
allow-listed, ...) is gone. The same text is what lands in the local logs via
getLlmErrorDetails(). Gateways in front of OpenAI-compatible endpoints are thelikely source here:
{"error": "Gateway failed"}, or a body that is just a JSONstring.
Fix
getProviderMessage()accepts a string payload as the provider message. The objectshape keeps working exactly as before, and nothing else changes -
getLlmErrorDetails()(the shape used for logs and retry classification) is untouched.
Tests
New test in
packages/core/src/tests/llm-error.test.ts. Reproduced first:After the fix the same error renders
HTTP 502: Gateway failed [request ID: request-789].@vegamo/deepcode-coresuite: 383 tests, 381 pass, 0 fail, 2 skipped.The same suite on the unmodified base is 382 / 380 / 0 / 2 - the only delta is
the new test, so no neighbouring test moved.
npm run typecheck,npm run lint,npm run format:checkpass.Related shape upstream (not part of this change)
A neighbouring agent project treats the same payload shape as a defect: a provider
returning a string
errorfield crashed their step, fixed by normalisingstring | objectbefore reading the message (opencode#49338 → opencode#49350). Thesemantics here are the same normalisation applied to the error-description path,
where the consequence is a lost message rather than a crash.