Commit Graph
1 Commits
Author SHA1 Message Date
ggbdpq cfadcde168 provider: a model list OpenCode's key is refused is asked again bare, so the picker says what the vendor serves (#4900)
What changed: OpenCode's model lists are public - the vendor answers its
/models without a key. When a provider's keyed ask of the list is
refused (an expired or wrong key), the same list is asked once more
without credentials, and what the vendor serves is saved as the
provider's list. The picker then shows the vendor's word instead of
falling back to the models.dev catalog, which files free rows under
opencode-go that Go doesn't serve (cat-jam-free, minimax-m3.1-flash-free,
step-5-preview-free, longcat-2.5-preview-free) while missing the free
rows it does (beam-free). The retry is kept to OpenCode's own hosts
(IsOpenCode): no other vendor's list is known to answer bare, and a
partial public list would stand in for the keyed one. Multi-key
providers, account (sign-in) lists and the add form's List are not
covered.

Reviewed and ported (on origin/main 1b0340fdb, cherry-picked clean;
the hunk now sits in fetchList, which fetch was split into since):
- mote: TestOpenCodeListAskedBareWhenTheKeyIsRefused and
  TestOpenCodeListNotAskedBareAtAnotherHost green. With models.go put
  back to main and the tests kept, the first is red:
  "the bare ask should have answered where the key was refused: no
  model list: https://opencode.ai/zen/go/v1/models: (Invalid API key)".
- mote: go test -tags nogui ./internal/provider ./internal/catalog ok;
  go test -tags nogui -timeout 45m ./internal/gateway ok (1009s); go vet
  (darwin), GOOS=linux go vet -tags nogui, GOOS=windows go vet on
  provider, catalog and gateway ok; gofmt -l clean.
- Read: the bare retry follows any failed keyed ask, not only a 401/403
  (the list errors are untyped strings); a network failure costs one
  more ask and keeps the first error. Provider Test still probes each
  endpoint with the key, so an expired key is still shown red there.
Not tried: a real expired OpenCode Go key; the tests serve the vendor
from a stub transport, no network.

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
Generated-by: GLM-5.3-Flash (ZCode)
2026-11-05 18:31:16 +08:00