{"record":{"id":"f03782ed0a7106b7","repo":"alibaba/open-code-review","slug":"model-q-is-not-available-for-provider-q-availab","errorCode":null,"errorMessage":"model %q is not available for provider %q; available models: %s","messagePattern":"model %q is not available for provider %q; available models: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/llm/resolver.go","lineNumber":511,"sourceCode":"\tvar availableModels []string\n\tif isPreset {\n\t\tavailableModels = append(availableModels, preset.Models...)\n\t}\n\tavailableModels = append(availableModels, entry.Models...)\n\n\t// A preset's Models list doubles as an allowlist for --model. For an\n\t// ambient-auth provider it cannot: Bedrock identifiers are scoped to an\n\t// account and a region, and an application inference profile ARN — a\n\t// supported value, and the one to use when spend has to be attributed — can\n\t// never appear in a list compiled upstream. The list stays a picker for\n\t// `ocr config model`; it does not gate an override.\n\tgateOverrideOnModelList := !ambientAuth\n\n\t// Apply model override with validation.\n\tif modelOverride != \"\" {\n\t\tif gateOverrideOnModelList && len(availableModels) > 0 {\n\t\t\tif !ModelListContains(availableModels, modelOverride) {\n\t\t\t\treturn ResolvedEndpoint{}, false, fmt.Errorf(\n\t\t\t\t\t\"model %q is not available for provider %q; available models: %s\",\n\t\t\t\t\tmodelOverride,\n\t\t\t\t\tcfg.Provider,\n\t\t\t\t\tstrings.Join(availableModels, \", \"),\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t\tmodel = modelOverride\n\t}\n\n\tif model == \"\" {\n\t\treturn ResolvedEndpoint{}, false, fmt.Errorf(\"provider %q has no model configured; run 'ocr config model' to select one or pass --model\", cfg.Provider)\n\t}\n\n\tif protocol == ProtocolAnthropic {\n\t\tvar err error\n\t\tah := \"authorization\"\n\t\tif isPreset && authHeader != \"\" {","sourceCodeStart":493,"sourceCodeEnd":529,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/internal/llm/resolver.go#L493-L529","documentation":"When a --model override is passed, the resolver validates it against the provider's model list (preset models plus entry models), when such a list exists. Bedrock/ambient-auth providers skip this gate because their model identifiers are account/region-scoped. This error means the requested model is not in the provider's known list.","triggerScenarios":"Running `ocr review --model <name>` (or ResolveEndpointWithModelOverride) where the model name does not match any entry in the provider's Models list while the list is non-empty and the provider is not ambient-auth.","commonSituations":"Typos in the model name; using a model alias not present in the preset's compiled list; a newly released model added upstream after the list was frozen; picking an OpenAI model name for an Anthropic preset.","solutions":["Run `ocr config model` to see and pick from the provider's available models","Pass a model name exactly as listed in the error's \"available models\" list","Add the model to the provider entry's models list if your endpoint genuinely serves it","If the model is account/region-scoped (Bedrock), use a bedrock provider so the list gate does not apply"],"exampleFix":"// before\nocr review --model claude-opus-4-20250514\n// error: model \"claude-opus-4-20250514\" is not available ...\n\n// after\nocr review --model claude-sonnet-4-20250514  // a model from the available list","handlingStrategy":"validation","validationCode":"// Go: validate the --model override against the provider's list first\nfunc modelAllowed(model string, availableModels []string) error {\n\tif len(availableModels) == 0 {\n\t\treturn nil\n\t}\n\tfor _, m := range availableModels {\n\t\tif m == model {\n\t\t\treturn nil\n\t\t}\n\t}\n\treturn fmt.Errorf(\"model %q not in list; available: %s\", model, strings.Join(availableModels, \", \"))\n}","typeGuard":"func isKnownModel(model string, available []string) bool {\n\tfor _, m := range available {\n\t\tif m == model {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}","tryCatchPattern":"ep, ok, err := resolver.ResolveEndpointWithModelOverride(cfg, modelOverride)\nif err != nil && strings.Contains(err.Error(), \"is not available for provider\") {\n\tfmt.Fprintf(os.Stderr, \"pick one of: %v\\n\", err)\n\tos.Exit(2)\n}","preventionTips":["Run `ocr config model` to list valid models before passing --model","Copy model names exactly from the error's available-models list (no aliases)","When a provider gains a new model, add it to the entry's models list","Use a bedrock/ambient-auth provider when identifiers are ARNs not in any static list"],"tags":["config","model","validation"],"backgroundTag":"model-not-found","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}