Skip to content

fix(ai): show provider error bodies when no message is recognized - #51978

Merged
rekram1-node merged 2 commits into
v2from
provider-error-body
Sep 29, 2026
Merged

rekram1-node merged 2 commits into
v2from
provider-error-body

Conversation

@rekram1-node

@rekram1-node rekram1-node commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

#42610 removed the executor's redaction logic, but it also removed the raw-body fallback. When a provider's error body has no error.message or top-level message, users now see only Provider request failed with HTTP N, even though the provider explained the problem.

Live examples that currently show only the generic message: Mistral {"detail":"Invalid API Key"}, NVIDIA {"title":"Gone","detail":"The model ... has reached its end of life ..."}, xAI {"code":"invalid-argument","error":"Incorrect API key provided..."}, Cloudflare {"errors":[{"message":"Authentication error"}]}.

Fix

In packages/ai/src/route/executor.ts, without a recognized message, show the status and the raw body, capped at 2,000 characters:

Provider request failed with HTTP 401: {"detail":"Invalid API Key"}
  • The body is not redacted or otherwise rewritten, only truncated.
  • HTML error pages from gateways and proxies, and empty bodies, keep the generic message, as in v1.
  • reason.body still holds the complete body, and classification and retries are unchanged.

Recognizing more provider message layouts and fixing classification gaps will come in follow-up PRs.

Tests

  • New tests cover an unrecognized JSON body, truncation, and HTML pages.
  • Two existing expectations change: plain-text and blank-message bodies now include the body.
  • bun test in packages/ai and bun run check pass.

@rekram1-node rekram1-node changed the title fix(ai): show provider error bodies when no message field is recognized fix(ai): show provider error bodies when no message is recognized Sep 29, 2026
@rekram1-node
rekram1-node merged commit 14af33d into v2 Sep 29, 2026
8 checks passed
@rekram1-node
rekram1-node deleted the provider-error-body branch September 29, 2026 05:06
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.

1 participant