alibaba/open-code-review · error

invalid boolean for telemetry.content_logging: %w

Error message

invalid boolean for telemetry.content_logging: %w

What it means

The telemetry.content_logging key is parsed with strconv.ParseBool; a value Go cannot interpret as a boolean produces "invalid boolean for telemetry.content_logging: %w" with the strconv parse error attached.

Source

Thrown at cmd/opencodereview/config_cmd.go:585

	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
		if err := json.Unmarshal([]byte(value), &m); err != nil {
			return fmt.Errorf("invalid JSON for llm.extra_body: %w", err)
		}
		cfg.Llm.ExtraBody = m
	case "llm.retry_codes", "llm.RetryCodes":
		codes, warnings, err := llm.ParseRetryCodes(value)
		if err != nil {
			return err
		}
		for _, w := range warnings {
			fmt.Fprintf(os.Stderr, "[ocr] WARNING: %s\n", w)
		}
		cfg.Llm.RetryCodes = codes

View on GitHub (pinned to 5cf97d0d15)

Solutions

  1. Use `ocr config set telemetry.content_logging true` (or false)
  2. Use 1/0 in scripts
  3. Quote the value so the shell doesn't split or drop it
  4. Confirm with `ocr config get` that the value took effect

Example fix

// before
ocr config set telemetry.content_logging on
// after
ocr config set telemetry.content_logging true
Defensive patterns

Strategy: validation

Validate before calling

if _, err := strconv.ParseBool(v); err != nil {
    return fmt.Errorf("telemetry.content_logging must be true/false, got %q", v)
}
_ = runConfigSet("telemetry.content_logging", v)

Try / catch

if err := runConfigSet("telemetry.content_logging", v); err != nil {
    if strings.Contains(err.Error(), "invalid boolean for telemetry.content_logging") {
        fmt.Fprintf(os.Stderr, "expected true/false, got %q\n", v)
    }
}

Prevention

When it happens

Trigger: `ocr config set telemetry.content_logging yes|on|""|1.0` — anything outside strconv.ParseBool's accepted set.

Common situations: Trying to turn content logging on with "yes"; templated config where the placeholder was never substituted; copy-pasting YAML conventions into the CLI.

Related errors


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