fix(run): report a failed provider list as itself, not "Model not found"

Merged
RA
1d ago
+82-1

Issue for this PR

Closes #1468

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

run --model checks the model against the server's provider list before it starts a session. It read a failed provider.list call as an empty list, so an error response, no response, or a body that was not the list all ended in "Model not found".

New src/cli/cmd/run/provider-list.ts returns the list when the body has one, and otherwise throws "Could not load the provider list to check --model ()". The detail is the HTTP status or "no response", plus the error message or body when there is one. run.ts uses it in place of .data?.all ?? []. A model missing from a successful list is still "Model not found".

This does not fix #1340. That flaky test fails with exactly the old message, so after this its next failure will show what the provider list call returned.

How did you verify your code works?

  • test/cli/run/provider-list.test.ts: a successful list, an empty list, and five failure shapes (JSON error body, thrown error with no response, empty error, 200 with a non-list body, non-2xx with no body), each with the exact message and never "Model not found".
  • test/cli/run/run-process.test.ts (real CLI subprocesses): 5 pass, including the unknown-model test that expects a prompt nonzero exit.
  • test/cli/run: 225 pass. tsgo --noEmit for opencode passes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

🤖 Generated with Claude Code

https://claude.ai/code/session_0174HUYiaceApqHP7EKMNgnb


Summary by cubic

run --model checked the model against the server's provider list before starting a session, but read a failed list call as an empty list. That meant any server error, missing response, or a body that wasn't the expected JSON showed up as "Model not found". Now the check throws an error naming the failing call, with the HTTP status (or "no response") and any server detail. A model missing from a successful list still reports "Model not found".