alibaba/open-code-review · error
invalid boolean for telemetry.enabled: %w
Error message
invalid boolean for telemetry.enabled: %w
What it means
Raised when the value for `ocr config set telemetry.enabled` (or telemetry.Enable) is not a boolean Go can parse (strconv.ParseBool accepts 1/t/T/true/TRUE/True/0/f/F/false/FALSE/False). The telemetry struct's Enabled field is a plain bool, so any other string would silently fail to be stored; the setter converts the parse error into a wrapped, user-facing error naming the key.
Source
Thrown at cmd/opencodereview/config_cmd.go:572
if err != nil {
return fmt.Errorf("invalid boolean for llm.use_anthropic: %w", err)
}
cfg.Llm.UseAnthropic = &b
// Mirror protocol for backward compatibility. true always selects
// anthropic. false only mirrors to the legacy openai default when
// protocol is unset or already a legacy value (anthropic/openai);
// openai-responses is preserved to avoid a silent downgrade.
if b {
cfg.Llm.Protocol = llm.ProtocolAnthropic
} else if cfg.Llm.Protocol == "" || cfg.Llm.Protocol == llm.ProtocolAnthropic || cfg.Llm.Protocol == llm.ProtocolOpenAIChatCompletions {
cfg.Llm.Protocol = llm.ProtocolOpenAIChatCompletions
}
case "language", "Language":
cfg.Language = value
case "telemetry.enabled", "telemetry.Enabled":
b, err := strconv.ParseBool(value)
if err != nil {
return fmt.Errorf("invalid boolean for telemetry.enabled: %w", err)
}
cfg.ensureTelemetry()
cfg.Telemetry.Enabled = b
case "telemetry.exporter", "telemetry.Exporter":
cfg.ensureTelemetry()
cfg.Telemetry.Exporter = value
case "telemetry.otlp_endpoint", "telemetry.OTLPEndpoint":
cfg.ensureTelemetry()
cfg.Telemetry.OTLPEndpoint = value
case "telemetry.content_logging", "telemetry.ContentLog":
b, err := strconv.ParseBool(value)
if err != nil {
return fmt.Errorf("invalid boolean for telemetry.content_logging: %w", err)
}
cfg.ensureTelemetry()
cfg.Telemetry.ContentLog = b
case "llm.extra_body", "llm.ExtraBody":
var m map[string]anyView on GitHub (pinned to 5cf97d0d15)
Solutions
- Run `ocr config set telemetry.enabled false` (or true)
- Use 1/0 if scripting: `ocr config set telemetry.enabled 0`
- Verify the value in CI pipelines isn't an unset variable expanding to empty string
- Check other telemetry settings with `ocr config get`
Example fix
// before
ocr config set telemetry.enabled $TELEMETRY # expands to empty
// after
ocr config set telemetry.enabled "${TELEMETRY:-false}" Defensive patterns
Strategy: validation
Validate before calling
if _, err := strconv.ParseBool(v); err != nil {
return fmt.Errorf("telemetry.enabled must be true/false, got %q", v)
}
_ = runConfigSet("telemetry.enabled", v) Try / catch
if err := runConfigSet("telemetry.enabled", v); err != nil {
if strings.Contains(err.Error(), "invalid boolean for telemetry.enabled") {
fmt.Fprintf(os.Stderr, "pass true/false; got %q\n", v)
}
} Prevention
- Use "true"/"false" literally in scripts; avoid YAML-style yes/no
- Guard CI variables: "${TELEMETRY_ENABLED:-false}" so empty never reaches the CLI
- Parse user input with strconv.ParseBool before passing through
- Confirm the setting with `ocr config get`
When it happens
Trigger: `ocr config set telemetry.enabled <value>` where value is not one of 1/t/true/0/f/false (e.g. "yes", "on", "enable", empty).
Common situations: Disabling telemetry with "no"; an empty CI variable interpolated into the command; locale or YAML-style "Y"/"N" values.
Related errors
- invalid boolean for telemetry.content_logging: %w
- invalid boolean for llm.use_anthropic: %w
- load config: %w
- unset supports provider, max_tokens, effort, custom_provider
- MCP server %q not found
AI-assisted analysis of alibaba/open-code-review@5cf97d0d15 (2026-09-02).
Data as JSON: /api/errors/7547543bdccef143.
Report an issue: GitHub.