{"record":{"id":"926eb7bd153d1e04","repo":"cube-js/cube","slug":"could-not-parse-environment-variable-with-926eb7","errorCode":null,"errorMessage":"could not parse environment variable '{}' with '{}' value: {}","messagePattern":"could not parse environment variable '(.+?)' with '(.+?)' value: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"rust/cubestore/cubestore/src/config/mod.rs","lineNumber":1458,"sourceCode":"        Err(_) => default,\n    }\n}\n\npub fn env_parse_duration<T>(name: &str, default: T, max: Option<T>, min: Option<T>) -> T\nwhere\n    T: FromStr + PartialOrd + Display,\n    T::Err: Display,\n{\n    let v = match env::var(name).ok() {\n        None => {\n            return default;\n        }\n        Some(v) => v,\n    };\n\n    let n = match v.parse::<T>() {\n        Ok(n) => n,\n        Err(e) => panic!(\n            \"could not parse environment variable '{}' with '{}' value: {}\",\n            name, v, e\n        ),\n    };\n\n    if let Some(max) = max {\n        if n > max {\n            panic!(\n                \"wrong configuration for environment variable '{}' with '{}' value: greater then max size {}\",\n                name, v,\n                max\n            )\n        }\n    };\n\n    if let Some(min) = min {\n        if n < min {\n            panic!(","sourceCodeStart":1440,"sourceCodeEnd":1476,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/rust/cubestore/cubestore/src/config/mod.rs#L1440-L1476","documentation":"The numeric environment-variable helper parses the variable's string value with `T::from_str` and panics if parsing fails, embedding the parse error in the message. It fires when an integer-typed Cube Store env var contains text that is not a valid number of the expected type.","triggerScenarios":"Setting a numeric Cube Store env var to a non-integer or out-of-type value — e.g. `VAR=1000ms` (suffix not allowed), `VAR=1_000` (underscores), `VAR=1.5` for an integer type, or a value that overflows the target type.","commonSituations":"Appending units to numbers out of habit; copy-pasting values with units or thousands separators; YAML/K8s manifests quoting values with whitespace; oversized numbers exceeding the integer type's range.","solutions":["Set the variable to a plain bare number valid for the expected type (e.g. `60000`, not `60s` or `1_000`).","Convert unit-bearing values yourself: `60s` → `60000` (ms), `5m` → `300`.","Check the parse error in the message for specifics (invalid digit vs. overflow) and correct the value accordingly."],"exampleFix":"// before\nCUBEJS_ROLLUP_ONLY_MAX_WORKER_THREADS=4x\n\n// after\nCUBEJS_ROLLUP_ONLY_MAX_WORKER_THREADS=4","handlingStrategy":"validation","validationCode":"fn validate_int_env(name: &str) -> Result<(), String> {\n    match std::env::var(name) {\n        Ok(v) => v.trim().parse::<i64>().map(|_| ()).map_err(|e| format!(\"{}='{}' is not a valid integer: {}\", name, v, e)),\n        Err(_) => Ok(()),\n    }\n}\nvalidate_int_env(\"CUBEJS_WORKER_THREADS\")?;","typeGuard":"fn is_plain_integer(v: &str) -> bool {\n    !v.trim().is_empty() && v.trim().chars().all(|c| c.is_ascii_digit())\n}","tryCatchPattern":"// Launch-time guard: parse the same value the server will parse.\nmatch \"64s\".parse::<usize>() {\n    Ok(n) => println!(\"ok: {}\", n),\n    Err(e) => eprintln!(\"env value rejected by cubestore, fix before starting: {}\", e),\n}","preventionTips":["Pass bare numbers only — strip units, underscores, commas, and whitespace.","Precompute unit conversions (60s → 60000) in your config generation script.","Check the target integer type's range; overflow also lands in this panic."],"tags":["configuration","environment-variables","parsing","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"}