{"record":{"id":"54a415fcbadcb68d","repo":"alibaba/open-code-review","slug":"provider-q-is-not-configured-set-a-core-field-fi","errorCode":null,"errorMessage":"provider %q is not configured; set a core field first (protocol is required for every custom provider):\n  ocr config set %s.protocol <protocol>","messagePattern":"provider %q is not configured; set a core field first \\(protocol is required for every custom provider\\):\n  ocr config set (.+?)\\.protocol <protocol>","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/opencodereview/config_cmd.go","lineNumber":831,"sourceCode":"\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}\n\tif cfg.CustomProviders == nil {\n\t\tcfg.CustomProviders = make(map[string]ProviderEntry)\n\t}\n\tentry := cfg.CustomProviders[name]\n\tif err := applyProviderField(name, &entry, field, key, value); err != nil {\n\t\treturn err\n\t}\n\tcfg.CustomProviders[name] = entry\n\treturn nil\n}\n\nfunc setMCPServerValue(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 MCP server key %q: expected mcp_servers.<name>.<field>\", key)\n\t}\n\tname, field := parts[1], parts[2]","sourceCodeStart":813,"sourceCodeEnd":849,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/cmd/opencodereview/config_cmd.go#L813-L849","documentation":"Auxiliary provider fields (anything other than core fields like protocol) cannot be the first thing set for a custom provider: the entry must already exist in cfg.CustomProviders. This forces the user to establish the provider with a core field (protocol is mandatory) before adding optional settings, so the protocol is known before auxiliary validation.","triggerScenarios":"`ocr config set custom_providers.newprovider.extra_headers 'X: y'` where custom_providers.newprovider has never been created (no core field set yet).","commonSituations":"Skipping straight to tweaking retries/headers on a brand-new custom provider; following documentation that omits the protocol step; a typo in the provider name that matches no existing entry.","solutions":["First set a core field, e.g. ocr config set custom_providers.<name>.protocol <protocol>","Verify the provider name spelling matches an already-configured custom provider","Then re-run the auxiliary field setting (extra_headers, retry_codes, aws_*, etc.)"],"exampleFix":"// before\nocr config set custom_providers.newprov.retry_codes \"429\"\n// after\nocr config set custom_providers.newprov.protocol openai\nocr config set custom_providers.newprov.retry_codes \"429\"","handlingStrategy":"validation","validationCode":"name=\"newprovider\"\nocr config get custom_providers.\"$name\".protocol >/dev/null 2>&1 || ocr config set custom_providers.\"$name\".protocol openai","typeGuard":null,"tryCatchPattern":"if _, exists := cfg.CustomProviders[name]; isAuxiliaryProviderField(field) && !exists {\n    return fmt.Errorf(\"provider %q is not configured; set a core field first\", name)\n}","preventionTips":["Always set protocol (or another core field) when creating a custom provider","Double-check provider name spelling to avoid hitting a nonexistent entry","Set auxiliary fields only after the provider exists in config"],"tags":["cli","config","prerequisite"],"backgroundTag":"missing-required-config-field","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}