{"record":{"id":"e67b994e2d81fe34","repo":"alibaba/open-code-review","slug":"s-does-not-apply-to-provider-q-aws-region-and-a","errorCode":null,"errorMessage":"%s does not apply to provider %q: aws_region and aws_profile are only used by providers that authenticate from the AWS credential chain (protocol %s)","messagePattern":"(.+?) does not apply to provider %q: aws_region and aws_profile are only used by providers that authenticate from the AWS credential chain \\(protocol (.+?)\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/opencodereview/config_cmd.go","lineNumber":680,"sourceCode":"\t\t\treturn fmt.Errorf(\"invalid extra headers for %s: %w\", key, err)\n\t\t}\n\t\tentry.ExtraHeaders = parsed\n\tcase \"retry_codes\":\n\t\tcodes, warnings, err := llm.ParseRetryCodes(value)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"invalid retry codes for %s: %w\", key, err)\n\t\t}\n\t\tfor _, w := range warnings {\n\t\t\tfmt.Fprintf(os.Stderr, \"[ocr] WARNING: %s\\n\", w)\n\t\t}\n\t\tentry.RetryCodes = codes\n\tcase \"aws_region\", \"aws_profile\":\n\t\tnormalized, err := normalizeAWSSetting(field, key, value)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif !providerAcceptsAWSSettings(providerName, entry) {\n\t\t\treturn fmt.Errorf(\"%s does not apply to provider %q: aws_region and aws_profile are only used by providers that authenticate from the AWS credential chain (protocol %s)\", field, providerName, llm.ProtocolAnthropicBedrock)\n\t\t}\n\t\tif field == \"aws_region\" {\n\t\t\tentry.AWSRegion = normalized\n\t\t} else {\n\t\t\tentry.AWSProfile = normalized\n\t\t}\n\tdefault:\n\t\treturn fmt.Errorf(\"unknown provider field %q: supported fields are api_key, api_key_cmd, url, protocol, model, models, auth_header, extra_body, extra_headers, retry_codes, aws_region, aws_profile\", field)\n\t}\n\treturn nil\n}\n\n// providerAcceptsAWSSettings reports whether aws_region / aws_profile mean\n// anything for this provider. Storing them anywhere else would be dead config\n// that reads as applied, so it is rejected instead.\n//\n// The entry's own protocol decides whenever it sets one: a preset's protocol can\n// be overridden per entry (see tryProviderConfig), so `protocol: openai` on the","sourceCodeStart":662,"sourceCodeEnd":698,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/cmd/opencodereview/config_cmd.go#L662-L698","documentation":"This error rejects aws_region or aws_profile set on a provider that does not authenticate through the AWS credential chain. providerAcceptsAWSSettings checks the provider's protocol; only AWS-backed protocols (protocol anthropic-bedrock) make these fields meaningful, and storing them elsewhere would be silently dead configuration.","triggerScenarios":"`ocr config set providers.<name>.aws_region us-east-1` (or aws_profile) where the provider entry's protocol is not anthropic-bedrock — e.g. a preset openai/anthropic provider or a custom provider with protocol openai.","commonSituations":"Copying a Bedrock-focused config snippet to a non-Bedrock provider; switching a provider's protocol away from bedrock and forgetting the old aws_* fields are now invalid to (re)set; typos in the protocol field.","solutions":["Set the provider's protocol to anthropic-bedrock before setting aws_region/aws_profile","Remove the aws_region/aws_profile setting if the provider genuinely is not Bedrock-backed","Use a provider entry (or custom provider) whose protocol is llm.ProtocolAnthropicBedrock"],"exampleFix":"// before\nocr config set custom_providers.foo.protocol openai\nocr config set custom_providers.foo.aws_region us-east-1\n// after\nocr config set custom_providers.foo.protocol anthropic-bedrock\nocr config set custom_providers.foo.aws_region us-east-1","handlingStrategy":"validation","validationCode":"protocol=$(ocr config get providers.foo.protocol)\n[[ \"$protocol\" == \"anthropic-bedrock\" ]] || echo \"aws_region/aws_profile only apply to anthropic-bedrock providers\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only set aws_region/aws_profile on providers whose protocol is anthropic-bedrock","After changing a provider's protocol away from bedrock, do not re-add aws_* settings","Check the provider's protocol with ocr config get first"],"tags":["cli","config","aws","bedrock"],"backgroundTag":"config-field-not-applicable","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}