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]any

View on GitHub (pinned to 5cf97d0d15)

Solutions

  1. Run `ocr config set telemetry.enabled false` (or true)
  2. Use 1/0 if scripting: `ocr config set telemetry.enabled 0`
  3. Verify the value in CI pipelines isn't an unset variable expanding to empty string
  4. 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

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


AI-assisted analysis of alibaba/open-code-review@5cf97d0d15 (2026-09-02). Data as JSON: /api/errors/7547543bdccef143. Report an issue: GitHub.