{"record":{"id":"b88d30caa7631924","repo":"cube-js/cube","slug":"expected-0-1-true-false-for-found","errorCode":null,"errorMessage":"expected '0'/'1'/true/false for '{}', found '{}'","messagePattern":"expected '0'/'1'/true/false for '(.+?)', found '(.+?)'","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"rust/cubestore/cubestore/src/config/mod.rs","lineNumber":1378,"sourceCode":"            other => {\n                log::warn!(\n                    \"unknown {} value '{}', using default (full_merge)\",\n                    name,\n                    other\n                );\n                TopKAggregateStrategy::FullMerge\n            }\n        },\n    }\n}\n\nfn env_bool(name: &str, default: bool) -> bool {\n    env::var(name)\n        .ok()\n        .map(|x| match x.as_str() {\n            \"0\" | \"false\" => false,\n            \"1\" | \"true\" => true,\n            _ => panic!(\"expected '0'/'1'/true/false for '{}', found '{}'\", name, &x),\n        })\n        .unwrap_or(default)\n}\n\n/// Recognizes the usual boolean spellings in either case; `None` for anything else, including an\n/// empty value.\nfn parse_flag(value: &str) -> Option<bool> {\n    match value.trim().to_ascii_lowercase().as_str() {\n        \"1\" | \"true\" | \"yes\" | \"on\" => Some(true),\n        \"0\" | \"false\" | \"no\" | \"off\" => Some(false),\n        _ => None,\n    }\n}\n\n/// Lenient boolean env read for toggles: falls back to `default` with a warning on a value\n/// [`parse_flag`] does not recognize. Unlike [`env_bool`] it never panics -- a malformed value on a\n/// performance flag must not take a node down on startup, and for a flag that is on by default the\n/// value an operator writes to turn it off is the one path that must work.","sourceCodeStart":1360,"sourceCodeEnd":1396,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/rust/cubestore/cubestore/src/config/mod.rs#L1360-L1396","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Change the variable's value to one of 0, 1, true, or false (lowercase).","Unset the variable entirely if you want the documented default (unset falls back to `default`, but an empty string does not).","Audit startup scripts/manifests for quoted or empty values (`VAR=\"\"` panics) and remove them."],"exampleFix":"// before (docker-compose / shell)\nexport CUBEJS_TELEMETRY=TRUE\n\n// after\nexport CUBEJS_TELEMETRY=true","handlingStrategy":"validation","validationCode":"const BOOL_VARS: [(&str, &str); 1] = [(\"CUBEJS_TELEMETRY\", \"true\")];\nfor (name, val) in BOOL_VARS {\n    if let Ok(v) = std::env::var(name) {\n        assert!(matches!(v.as_str(), \"0\" | \"1\" | \"true\" | \"false\"),\n            \"{} must be 0/1/true/false, got '{}'\", name, v);\n    }\n}","typeGuard":"fn is_valid_bool_env(v: &str) -> bool {\n    matches!(v, \"0\" | \"1\" | \"true\" | \"false\")\n}","tryCatchPattern":"// The panic occurs at startup; validate env before launching the binary.\nlet out = std::process::Command::new(\"cubestored\").env(\"CUBEJS_TELEMETRY\", \"yes\").output()?;\nif !out.status.success() {\n    let msg = String::from_utf8_lossy(&out.stderr);\n    if msg.contains(\"expected '0'/'1'/true/false\") {\n        eprintln!(\"fix the boolean env value and relaunch\");\n    }\n}","preventionTips":["Use only lowercase 0/1/true/false for boolean env vars — not yes/no/on/off/TRUE.","Prefer unsetting a variable over setting it to an empty string; empty strings panic.","Lint Docker/K8s/CI env blocks for boolean-typed Cube Store variables at review time."],"tags":["configuration","environment-variables","panics","startup"],"backgroundTag":"invalid-env-var-value","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}