fix(ai-gateway): make 'model broken' errors actionable instead of a bare 404#3924
Merged
Merged
Conversation
…are 404 Closes #3786. When a provider returns 404/400 for a model (the id isn't enabled for the user's account or API key), the cascade exhausts and friendlyError produced a generic "<model> request failed (404). Please try again or pick a different model." That reads like a transient glitch, so users retry the same model forever. 404 is classified transient (Vertex missing-model fallback), so they also see the empty "No response from model" fallback. Neither says the real cause. Add explicit cases: - 404 / 400: the model isn't available on your account or API key; pick a different model or check your provider/key access (with a fell-through variant when every fallback also failed). - 401 / 403: the provider rejected the request; check the API key in your AI preset. No model-list changes: the gpt-5.x ids are intentional (full pricing/usage tables + passing model tests); this only clarifies the failure when a given key lacks access. friendlyError is now exported and covered by a unit test. Verified: `bun test src/test/friendly-error.unit.test.ts` (6 pass). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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
Closes #3786.
Users picking certain models get cryptic errors and assume the app is broken:
A provider
404/400for a model almost always means the model id isn't enabled for that account or API key, not a transient outage. ButfriendlyErrorreturned the generic"<model> request failed (404)", which reads like a glitch, so users retry the same model indefinitely. (And because404is classified transient for the Vertex missing-model fallback, they also hit the emptyNo response from modelpath.)Fix (
friendlyError, unit-tested)404/400: model not enabled on this account/key (plus a fell-through variant when every fallback model also failed)401/403: provider rejected the request, check the API key in your AI preset408/429/5xx) and generic messaging unchangedTesting
friendlyErroris now exported and covered by a new unit test:🤖 Generated with Claude Code