You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[bug] opencode run: unknown model returns a generic 500 UnknownError instead of a 404 with the "did you mean" message #47162
The prompt service already publishes a Model not found: provider/model. Did you mean ...? event, then dies with the raw error, and the HTTP error middleware maps every defect to UnknownError. The prompt endpoint already declares a 404 error type with a message field, so the fix is to convert the provider error into that before it dies.
Same class of problem as the secondary point in #47080.
Plugins
None
OpenCode version
1.18.27
Steps to reproduce
1. Install 1.18.27 to a scratch prefix and use an empty HOME so no real config or auth is involved:
2. Run with a model id that is not in the OpenRouter catalog:
env -i PATH="$PATH" HOME=/tmp/oc-test/home OPENROUTER_API_KEY=sk-or-invalid TERM=dumb \
/tmp/oc-test/bin/opencode run --print-logs --log-level DEBUG \
-m openrouter/does-not-exist-xyz --format json "Reply with the single word pong."echo"exit=$?"
stdout:
{"type":"error","sessionID":"ses_...","error":{"name":"UnknownError","data":{"message":"Unexpected server error. Check server logs for details.","ref":"err_00111007"}}}
stderr (server log) already has the useful message:
level=ERROR message=failed ref=err_00111007 error="ProviderModelNotFoundError: Model not found: openrouter/does-not-exist-xyz. Did you mean: dots-studio/dots-3-note-preview:free?"
at SessionPrompt.getModel ...
Exit 1.
3. Same command with a real model id and the same bad key, for comparison:
env -i PATH="$PATH" HOME=/tmp/oc-test/home OPENROUTER_API_KEY=sk-or-invalid TERM=dumb \
/tmp/oc-test/bin/opencode run -m openrouter/openai/gpt-4o-mini \
--format json "Reply with the single word pong."
A bad key gets a specific, typed error, but an unknown model gets an opaque 500 and the caller has to go read the server log. No network call is made in step 2, the failure is local.
Expected Result
Step 2 returns a 404 NotFoundError carrying the Model not found: ... Did you mean ... message, and exits 1.
changed the title [-]opencode run: unknown model returns a generic 500 UnknownError instead of a 404 with the "did you mean" message[/-][+][bug] opencode run: unknown model returns a generic 500 UnknownError instead of a 404 with the "did you mean" message[/+]on Sep 3, 2026
I can take this as well if desired. Plan: in SessionPrompt.getModel, fail with the NotFoundError the prompt endpoint already declares, carrying the existing "Model not found ... Did you mean" message, instead of dying into the generic 500. No schema change required.
Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.
Activity
[-]opencode run: unknown model returns a generic 500 UnknownError instead of a 404 with the "did you mean" message[/-][+][bug] opencode run: unknown model returns a generic 500 UnknownError instead of a 404 with the "did you mean" message[/+]thossullivan commentedon Sep 3, 2026
I can take this as well if desired. Plan: in SessionPrompt.getModel, fail with the NotFoundError the prompt endpoint already declares, carrying the existing "Model not found ... Did you mean" message, instead of dying into the generic 500. No schema change required.
thdxr commentedon Oct 11, 2026
Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (
opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊