Skip to content

fix(ai-gateway): make 'model broken' errors actionable instead of a bare 404#3924

Merged
louis030195 merged 1 commit into
mainfrom
fix/3786-clearer-model-unavailable-error
Jun 9, 2026
Merged

fix(ai-gateway): make 'model broken' errors actionable instead of a bare 404#3924
louis030195 merged 1 commit into
mainfrom
fix/3786-clearer-model-unavailable-error

Conversation

@louis030195

@louis030195 louis030195 commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

before vs after

Problem

Closes #3786.

Users picking certain models get cryptic errors and assume the app is broken:

404 data: {"error":{"message":"gpt-5.5-pro request failed (404). Please try again
or pick a different model.","type":"api_error","code":"404"}}
AI error in chat: No response from model — try again or check your AI preset in settings.

A provider 404/400 for a model almost always means the model id isn't enabled for that account or API key, not a transient outage. But friendlyError returned the generic "<model> request failed (404)", which reads like a glitch, so users retry the same model indefinitely. (And because 404 is classified transient for the Vertex missing-model fallback, they also hit the empty No response from model path.)

Note: this is not a model-list change. The gpt-5.x ids are intentional (they have full pricing/usage tables and passing model tests). The problem is the error message when a given key lacks access.

Fix (friendlyError, unit-tested)

BEFORE:  gpt-5.5-pro request failed (404). Please try again or pick a different model.

AFTER:   "gpt-5.5-pro" isn't available on your account or API key (404). Pick a
         different model, or check that your provider or key has access to it.
  • 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 preset
  • transient (408/429/5xx) and generic messaging unchanged

Testing

friendlyError is now exported and covered by a new unit test:

bun test src/test/friendly-error.unit.test.ts
6 pass  0 fail  16 expect() calls

🤖 Generated with Claude Code

…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>
@louis030195 louis030195 merged commit 8156876 into main Jun 9, 2026
16 checks passed
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.

[bug] Screenpipe Claude GPT models are broken

1 participant