fix(provider): type model not found errors (#27334)

This commit is contained in:
Kit Langton
2026-05-13 18:23:09 -04:00
committed by GitHub
parent 5182a3698d
commit 55e0af1405
12 changed files with 340 additions and 69 deletions

View File

@@ -64,6 +64,23 @@ describe("cli.error", () => {
expect(formatted).toContain("Check your network, proxy, or VPN configuration and try again.")
})
test("formats legacy and tagged provider model errors the same way", () => {
const data = {
providerID: "anthropic",
modelID: "claude-sonet-4",
suggestions: ["claude-sonnet-4"],
}
const expected = [
"Model not found: anthropic/claude-sonet-4",
"Did you mean: claude-sonnet-4",
"Try: `opencode models` to list available models",
"Or check your config (opencode.json) provider/model names",
].join("\n")
expect(FormatError({ name: "ProviderModelNotFoundError", data })).toBe(expected)
expect(FormatError({ _tag: "ProviderModelNotFoundError", ...data })).toBe(expected)
})
test("formats cancelled UI errors as empty output", () => {
expect(FormatError(new UI.CancelledError())).toBe("")
})