{"record":{"id":"2d972aa8a9d09f7f","repo":"alibaba/open-code-review","slug":"invalid-model-list-for-s-w","errorCode":null,"errorMessage":"invalid model list for %s: %w","messagePattern":"invalid model list for (.+?): %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/opencodereview/config_cmd.go","lineNumber":644,"sourceCode":"\t\tif err := llm.ValidateProtocol(normalized); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tentry.Protocol = normalized\n\t\t// Switching away from bedrock leaves aws_region/aws_profile as dead\n\t\t// config that reads as applied but nothing reads it — clear both, the\n\t\t// same way the TUI drops url/api_key/auth_header when switching onto\n\t\t// bedrock (see cpAmbientProtocol in provider_tui.go).\n\t\tif normalized != llm.ProtocolAnthropicBedrock && (entry.AWSRegion != \"\" || entry.AWSProfile != \"\") {\n\t\t\tfmt.Fprintf(os.Stderr, \"[ocr] WARNING: clearing aws_region/aws_profile on %q: protocol %q does not use the AWS credential chain\\n\", providerName, normalized)\n\t\t\tentry.AWSRegion = \"\"\n\t\t\tentry.AWSProfile = \"\"\n\t\t}\n\tcase \"model\":\n\t\tentry.Model = value\n\tcase \"models\":\n\t\tmodels, err := parseModelListValue(value)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"invalid model list for %s: %w\", key, err)\n\t\t}\n\t\tentry.Models = models\n\tcase \"auth_header\":\n\t\tnormalized, err := llm.NormalizeAuthHeader(value)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tentry.AuthHeader = normalized\n\tcase \"extra_body\":\n\t\tvar m map[string]any\n\t\tif err := json.Unmarshal([]byte(value), &m); err != nil {\n\t\t\treturn fmt.Errorf(\"invalid JSON for %s: %w\", key, err)\n\t\t}\n\t\tentry.ExtraBody = m\n\tcase \"extra_headers\":\n\t\tparsed, err := llm.ParseExtraHeaders(value)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"invalid extra headers for %s: %w\", key, err)","sourceCodeStart":626,"sourceCodeEnd":662,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/cmd/opencodereview/config_cmd.go#L626-L662","documentation":"The provider-level models field is parsed by parseModelListValue; if the value cannot be parsed into a valid model list, applyProviderField wraps the failure as \"invalid model list for <key>: %w\" with the full dotted key.","triggerScenarios":"`ocr config set providers.<name>.models <value>` (or custom_providers path) with an empty list, malformed separators, or a structure parseModelListValue rejects.","commonSituations":"Passing comma-separated names where a JSON array is expected (or vice versa); quoting mistakes eating the separators; an empty string from an unset shell variable; switching providers and pasting the wrong list format.","solutions":["Check parseModelListValue's expected format (comma-separated names vs JSON array) and reformat the value","Provide at least one model name; an empty value produces no valid list","Quote the value so shell word-splitting doesn't break it: `ocr config set providers.x.models \"m1,m2\"`","Set a single default with the `model` field instead if you don't need a list"],"exampleFix":"// before\nocr config set providers.openai.models \"\"\n// after\nocr config set providers.openai.models \"gpt-4o,gpt-4o-mini\"","handlingStrategy":"validation","validationCode":"models := strings.Split(value, \",\")\nfor i, m := range models {\n    models[i] = strings.TrimSpace(m)\n}\nif len(models) == 0 || (len(models) == 1 && models[0] == \"\") {\n    return errors.New(\"models needs at least one model name\")\n}\n_ = runConfigSet(\"providers.openai.models\", strings.Join(models, \",\"))","typeGuard":null,"tryCatchPattern":"if err := runConfigSet(\"providers.openai.models\", v); err != nil {\n    if strings.Contains(err.Error(), \"invalid model list for\") {\n        fmt.Fprintf(os.Stderr, \"%q is not a valid model list; supply at least one model name\\n\", v)\n    }\n}","preventionTips":["Quote comma-separated values so the shell doesn't split them","Never pass an empty string as the list; use the single `model` field for one default","Trim spaces around each name","Match the format parseModelListValue expects (comma-separated names) rather than JSON arrays"],"tags":["config","models","validation","cli"],"backgroundTag":"invalid-list-format","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}