{"record":{"id":"49ae2ecfa3ce399d","repo":"alibaba/open-code-review","slug":"invalid-provider-key-q-expected-providers-name","errorCode":null,"errorMessage":"invalid provider key %q: expected providers.<name>.<field>","messagePattern":"invalid provider key %q: expected providers\\.<name>\\.<field>","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/opencodereview/config_cmd.go","lineNumber":792,"sourceCode":"}\n\n// ensureModelInList appends model to the end when missing; never reorders existing entries.\nfunc ensureModelInList(models []string, model string) []string {\n\tmodel = strings.TrimSpace(model)\n\tif model == \"\" {\n\t\treturn models\n\t}\n\tif llm.ModelListContains(models, model) {\n\t\treturn models\n\t}\n\tout := append([]string(nil), models...)\n\treturn append(out, model)\n}\n\nfunc setProviderValue(cfg *Config, key, value string) error {\n\tparts := strings.SplitN(key, \".\", 3)\n\tif len(parts) != 3 || parts[1] == \"\" || parts[2] == \"\" {\n\t\treturn fmt.Errorf(\"invalid provider key %q: expected providers.<name>.<field>\", key)\n\t}\n\tif _, isPreset := llm.LookupProvider(parts[1]); !isPreset {\n\t\treturn setCustomProviderField(cfg, parts[1], parts[2], key, value)\n\t}\n\tif cfg.Providers == nil {\n\t\tcfg.Providers = make(map[string]ProviderEntry)\n\t}\n\tentry := cfg.Providers[parts[1]]\n\tif err := applyProviderField(parts[1], &entry, parts[2], key, value); err != nil {\n\t\treturn err\n\t}\n\tcfg.Providers[parts[1]] = entry\n\treturn nil\n}\n\nfunc setCustomProviderValue(cfg *Config, key, value string) error {\n\tparts := strings.SplitN(key, \".\", 3)\n\tif len(parts) != 3 || parts[1] == \"\" || parts[2] == \"\" {","sourceCodeStart":774,"sourceCodeEnd":810,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/cmd/opencodereview/config_cmd.go#L774-L810","documentation":"setProviderValue parses provider config keys with the rigid shape providers.<name>.<field>. If splitting the key on dots does not yield exactly three non-empty parts, the key does not address a provider field and this error is returned, telling the user the expected format.","triggerScenarios":"`ocr config set providers <value>` (only two segments), `ocr config set providers.myprovider` (two segments), or `ocr config set providers..url x` / `ocr config set providers.myprovider. x` (empty name or field).","commonSituations":"Forgetting the field part of the key; shell interpolation producing an empty segment ($UNSET_VAR); applying key/value pairs from a script with missing fields.","solutions":["Supply the full three-part key: ocr config set providers.<name>.<field> <value>","Ensure the provider name and field are non-empty","If setting a custom provider, use custom_providers.<name>.<field> instead"],"exampleFix":"// before\nocr config set providers.myprovider\n// after\nocr config set providers.myprovider.protocol anthropic","handlingStrategy":"validation","validationCode":"key=\"providers.myprovider.url\"\ncount=$(awk -F. '{print NF}' <<< \"$key\")\n[[ \"$count\" -eq 3 ]] || echo \"key must be providers.<name>.<field>\"","typeGuard":null,"tryCatchPattern":"parts := strings.SplitN(key, \".\", 3)\nif len(parts) != 3 || parts[1] == \"\" || parts[2] == \"\" {\n    return fmt.Errorf(\"invalid provider key %q: expected providers.<name>.<field>\", key)\n}","preventionTips":["Always include all three key segments","Check that interpolated shell variables are non-empty","Use providers.* for presets, custom_providers.* for custom entries"],"tags":["cli","config","key-format"],"backgroundTag":"invalid-config-key-format","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}