{"record":{"id":"19f05a675693c8d8","repo":"alibaba/open-code-review","slug":"invalid-boolean-for-llm-use-anthropic-w","errorCode":null,"errorMessage":"invalid boolean for llm.use_anthropic: %w","messagePattern":"invalid boolean for llm\\.use_anthropic: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/opencodereview/config_cmd.go","lineNumber":555,"sourceCode":"\t\t// the point of setting rather than accepted and ignored at resolve time.\n\t\tif normalized == llm.ProtocolAnthropicBedrock {\n\t\t\treturn fmt.Errorf(\"llm.protocol cannot be %q: bedrock derives its host from aws_region and signs with the AWS credential chain, so it has no use for llm.url or llm.auth_token; run `ocr config set provider bedrock` instead\", normalized)\n\t\t}\n\t\tcfg.Llm.Protocol = normalized\n\t\t// Mirror use_anthropic so older binaries that predate llm.protocol\n\t\t// still pick the right protocol family: anthropic -> true, the OpenAI\n\t\t// family (including openai-responses) -> false.\n\t\tif normalized == llm.ProtocolAnthropic {\n\t\t\tt := true\n\t\t\tcfg.Llm.UseAnthropic = &t\n\t\t} else {\n\t\t\tf := false\n\t\t\tcfg.Llm.UseAnthropic = &f\n\t\t}\n\tcase \"llm.use_anthropic\", \"llm.UseAnthropic\":\n\t\tb, err := strconv.ParseBool(value)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"invalid boolean for llm.use_anthropic: %w\", err)\n\t\t}\n\t\tcfg.Llm.UseAnthropic = &b\n\t\t// Mirror protocol for backward compatibility. true always selects\n\t\t// anthropic. false only mirrors to the legacy openai default when\n\t\t// protocol is unset or already a legacy value (anthropic/openai);\n\t\t// openai-responses is preserved to avoid a silent downgrade.\n\t\tif b {\n\t\t\tcfg.Llm.Protocol = llm.ProtocolAnthropic\n\t\t} else if cfg.Llm.Protocol == \"\" || cfg.Llm.Protocol == llm.ProtocolAnthropic || cfg.Llm.Protocol == llm.ProtocolOpenAIChatCompletions {\n\t\t\tcfg.Llm.Protocol = llm.ProtocolOpenAIChatCompletions\n\t\t}\n\tcase \"language\", \"Language\":\n\t\tcfg.Language = value\n\tcase \"telemetry.enabled\", \"telemetry.Enabled\":\n\t\tb, err := strconv.ParseBool(value)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"invalid boolean for telemetry.enabled: %w\", err)\n\t\t}","sourceCodeStart":537,"sourceCodeEnd":573,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/cmd/opencodereview/config_cmd.go#L537-L573","documentation":"The llm.use_anthropic key accepts only Go strconv.ParseBool-compatible booleans (1, t, T, true, TRUE, 0, f, false...). Any other string fails to parse and the strconv error is wrapped as \"invalid boolean for llm.use_anthropic: %w\".","triggerScenarios":"`ocr config set llm.use_anthropic yes|on|Yes|1.0|<empty>` — values humans write for booleans that strconv.ParseBool rejects.","commonSituations":"Writing \"yes\"/\"no\" out of habit from YAML; leaving the value empty due to a shell variable that failed to expand; a provisioning script emitting \"enabled\"/\"disabled\".","solutions":["Use `true` or `false`: `ocr config set llm.use_anthropic true`","Prefer the modern key: `ocr config set llm.protocol anthropic` (or openai/openai-responses) which also mirrors use_anthropic","Check the shell variable actually expands to true/false (`echo $VAL`)","Note Go accepts \"1\"/\"0\" and \"t\"/\"f\" too, but not yes/no/on/off"],"exampleFix":"// before\nocr config set llm.use_anthropic yes\n// after\nocr config set llm.use_anthropic true","handlingStrategy":"validation","validationCode":"switch strings.ToLower(v) {\ncase \"true\", \"1\", \"t\": v = \"true\"\ncase \"false\", \"0\", \"f\": v = \"false\"\ndefault:\n    return fmt.Errorf(\"llm.use_anthropic needs true/false, got %q\", v)\n}\n_ = runConfigSet(\"llm.use_anthropic\", v)","typeGuard":null,"tryCatchPattern":"if err := runConfigSet(\"llm.use_anthropic\", v); err != nil {\n    if strings.Contains(err.Error(), \"invalid boolean for llm.use_anthropic\") {\n        fmt.Fprintf(os.Stderr, \"use true/false (Go ParseBool), not yes/no/on/off\\n\")\n    }\n}","preventionTips":["Only use true/false (or 1/0) — Go's strconv.ParseBool does not accept yes/no/on/off","Prefer `ocr config set llm.protocol anthropic|openai` which mirrors this flag automatically","Ensure shell variables expand before the command runs (`\"${VAR:?unset}\"`)","Verify with `ocr config get` after setting"],"tags":["config","boolean","go","cli"],"backgroundTag":"invalid-boolean-value","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}