cube-js/cube · critical

expected '0'/'1'/true/false for '{}', found '{}'

Error message

expected '0'/'1'/true/false for '{}', found '{}'

What it means

Cube Store parses boolean environment variables with `env_bool`, which only accepts exactly "0", "1", "true", or "false". Any other value for a boolean-typed env var makes startup `panic!` with this message naming the variable and the offending value. There is no fallback or warning — an unrecognized spelling is fatal at process start.

Source

Thrown at rust/cubestore/cubestore/src/config/mod.rs:1378

            other => {
                log::warn!(
                    "unknown {} value '{}', using default (full_merge)",
                    name,
                    other
                );
                TopKAggregateStrategy::FullMerge
            }
        },
    }
}

fn env_bool(name: &str, default: bool) -> bool {
    env::var(name)
        .ok()
        .map(|x| match x.as_str() {
            "0" | "false" => false,
            "1" | "true" => true,
            _ => panic!("expected '0'/'1'/true/false for '{}', found '{}'", name, &x),
        })
        .unwrap_or(default)
}

/// Recognizes the usual boolean spellings in either case; `None` for anything else, including an
/// empty value.
fn parse_flag(value: &str) -> Option<bool> {
    match value.trim().to_ascii_lowercase().as_str() {
        "1" | "true" | "yes" | "on" => Some(true),
        "0" | "false" | "no" | "off" => Some(false),
        _ => None,
    }
}

/// Lenient boolean env read for toggles: falls back to `default` with a warning on a value
/// [`parse_flag`] does not recognize. Unlike [`env_bool`] it never panics -- a malformed value on a
/// performance flag must not take a node down on startup, and for a flag that is on by default the
/// value an operator writes to turn it off is the one path that must work.

View on GitHub (pinned to 7d981676b3)

Solutions

  1. Change the variable's value to one of 0, 1, true, or false (lowercase).
  2. Unset the variable entirely if you want the documented default (unset falls back to `default`, but an empty string does not).
  3. Audit startup scripts/manifests for quoted or empty values (`VAR=""` panics) and remove them.

Example fix

// before (docker-compose / shell)
export CUBEJS_TELEMETRY=TRUE

// after
export CUBEJS_TELEMETRY=true
Defensive patterns

Strategy: validation

Validate before calling

const BOOL_VARS: [(&str, &str); 1] = [("CUBEJS_TELEMETRY", "true")];
for (name, val) in BOOL_VARS {
    if let Ok(v) = std::env::var(name) {
        assert!(matches!(v.as_str(), "0" | "1" | "true" | "false"),
            "{} must be 0/1/true/false, got '{}'", name, v);
    }
}

Type guard

fn is_valid_bool_env(v: &str) -> bool {
    matches!(v, "0" | "1" | "true" | "false")
}

Try / catch

// The panic occurs at startup; validate env before launching the binary.
let out = std::process::Command::new("cubestored").env("CUBEJS_TELEMETRY", "yes").output()?;
if !out.status.success() {
    let msg = String::from_utf8_lossy(&out.stderr);
    if msg.contains("expected '0'/'1'/true/false") {
        eprintln!("fix the boolean env value and relaunch");
    }
}

Prevention

When it happens

Trigger: Setting a boolean Cube Store environment variable (parsed via `env_bool`) to a value other than 0/1/true/false — e.g. `VAR=yes`, `VAR=TRUE`, `VAR=on`, or `VAR=` (empty string).

Common situations: Shell export typos; values copied from other tools that accept yes/on/off; uppercase TRUE from templating; an empty value left behind when a variable is set but not assigned; secrets managers injecting whitespace.

Understand the failure class

Background: "is not a valid" / "Invalid ... value" environment variable errors: how libraries validate env vars and what to do when they reject yours — this error's family across 48 libraries.

Related errors


AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02). Data as JSON: /api/errors/b88d30caa7631924. Report an issue: GitHub.