{"record":{"id":"97f08c44e668f8d4","repo":"cube-js/cube","slug":"could-not-parse-environment-variable-with","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":"error","filePath":"rust/cubesql/cubesql/src/config/mod.rs","lineNumber":454,"sourceCode":"    }\n}\n\npub fn env_parse<T>(name: &str, default: T) -> T\nwhere\n    T: FromStr,\n    T::Err: Display,\n{\n    env_optparse(name).unwrap_or(default)\n}\n\nfn env_optparse<T>(name: &str) -> Option<T>\nwhere\n    T: FromStr,\n    T::Err: Display,\n{\n    env::var(name).ok().map(|x| match x.parse::<T>() {\n        Ok(v) => v,\n        Err(e) => panic!(\n            \"Could not parse environment variable '{}' with '{}' value: {}\",\n            name, x, e\n        ),\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","sourceCodeStart":436,"sourceCodeEnd":472,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/rust/cubesql/cubesql/src/config/mod.rs#L436-L472","documentation":"env_optparse parses an environment variable into any FromStr type and panics if the value can't be parsed, embedding the variable name, raw value, and parse error. CubeSQL treats a malformed typed env var as a fatal startup misconfiguration.","triggerScenarios":"Setting an env var consumed via env_optparse/env_parse to a value the target type can't parse — e.g. a numeric option set to 'abc', a boolean set to 'yes' where only 'true'/'false' parse, or a hex/undecodable port number.","commonSituations":"Docker/K8s manifests with wrong env values; quoting issues that add stray spaces; editing configs by hand and using locale-specific number formats.","solutions":["Check the panic message for the variable name and offending value, then set a valid value for that type (integer, bool, etc.)","Use the exact literal formats the type parses (e.g. 'true'/'false', plain integers, no spaces/quotes)","Unset the variable to fall back to the default if a custom value isn't required"],"exampleFix":"// before\nCUBEJS_DB_MAX_POOL_SIZE=ten\n// after\nCUBEJS_DB_MAX_POOL_SIZE=10","handlingStrategy":"validation","validationCode":"// Validate env values before the process relies on them (shell preflight)\ncheck_int() { case \"$1\" in ''|*[!0-9]*) echo \"invalid integer: $1\"; exit 1;; esac; }\ncheck_bool() { case \"$1\" in true|false) ;; *) echo \"invalid bool (use true/false): $1\"; exit 1;; esac }\n[ -n \"$CUBEJS_DB_MAX_POOL_SIZE\" ] && check_int \"$CUBEJS_DB_MAX_POOL_SIZE\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use plain integers for numeric env vars; true/false for booleans","Trim quotes and whitespace in Docker/K8s env definitions","Unset optional vars to fall back to documented defaults","Run a config preflight script in CI/deploy before starting CubeSQL"],"tags":["rust","panic","environment-variable","configuration","parsing"],"backgroundTag":"missing-env-var","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}