{"record":{"id":"fc40e60886fc79ee","repo":"alibaba/open-code-review","slug":"custom-provider-name-q-conflicts-with-a-preset-pr","errorCode":null,"errorMessage":"custom provider name %q conflicts with a preset provider; use providers.%s.%s to configure the preset or choose a different custom provider name","messagePattern":"custom provider name %q conflicts with a preset provider; use providers\\.(.+?)\\.(.+?) to configure the preset or choose a different custom provider name","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/opencodereview/config_cmd.go","lineNumber":814,"sourceCode":"\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] == \"\" {\n\t\treturn fmt.Errorf(\"invalid custom provider key %q: expected custom_providers.<name>.<field>\", key)\n\t}\n\tif preset, isPreset := llm.LookupProvider(parts[1]); isPreset {\n\t\treturn fmt.Errorf(\"custom provider name %q conflicts with a preset provider; use providers.%s.%s to configure the preset or choose a different custom provider name\", parts[1], preset.Name, parts[2])\n\t}\n\treturn setCustomProviderField(cfg, parts[1], parts[2], key, value)\n}\n\nfunc isAuxiliaryProviderField(field string) bool {\n\tswitch field {\n\tcase \"extra_body\", \"extra_headers\", \"retry_codes\":\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}\n\nfunc setCustomProviderField(cfg *Config, name, field, key, value string) error {\n\tif _, exists := cfg.CustomProviders[name]; isAuxiliaryProviderField(field) && !exists {\n\t\tproviderKey := strings.TrimSuffix(key, \".\"+field)\n\t\treturn fmt.Errorf(\"provider %q is not configured; set a core field first (protocol is required for every custom provider):\\n  ocr config set %s.protocol <protocol>\", name, providerKey)\n\t}","sourceCodeStart":796,"sourceCodeEnd":832,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/cmd/opencodereview/config_cmd.go#L796-L832","documentation":"Custom provider names must not collide with built-in preset provider names. If llm.LookupProvider finds the requested custom name among presets, this error fires and suggests configuring the preset via providers.<name>.<field> or picking a different custom name.","triggerScenarios":"`ocr config set custom_providers.anthropic.api_key ...` or any custom_providers.* key whose <name> equals a preset provider name (e.g. anthropic, openai).","commonSituations":"Users assuming every provider must be declared under custom_providers even when it already exists as a preset; naming a custom gateway after the upstream vendor.","solutions":["If targeting a preset provider, set the field via providers.<name>.<field> instead","Rename the custom provider to a non-preset name, e.g. custom_providers.my-anthropic-proxy","List preset providers (docs/help) to pick an unused name"],"exampleFix":"// before\nocr config set custom_providers.openai.api_key sk-...\n// after\nocr config set providers.openai.api_key sk-...","handlingStrategy":"validation","validationCode":"name=\"myprovider\"\nocr config get providers.\"$name\".protocol 2>/dev/null && echo \"$name is a preset; use providers.$name.<field>\"","typeGuard":null,"tryCatchPattern":"if preset, isPreset := llm.LookupProvider(parts[1]); isPreset {\n    return fmt.Errorf(\"custom provider name %q conflicts with a preset provider; use providers.%s.%s\", parts[1], preset.Name, parts[2])\n}","preventionTips":["Configure preset providers under providers.*, not custom_providers.*","Choose custom names that do not match preset names","Prefix custom gateways, e.g. my-openai-proxy"],"tags":["cli","config","naming-conflict"],"backgroundTag":"config-name-conflict","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}