{"record":{"id":"a324b2577f4fa67b","repo":"cube-js/cube","slug":"could-not-parse-environment-variable-with-a324b2","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":475,"sourceCode":"        ),\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":457,"sourceCodeEnd":493,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/rust/cubesql/cubesql/src/config/mod.rs#L457-L493","documentation":"env_parse_duration parses an env var into a duration-like value: it first reads a unit suffix, then parses the numeric part with T::from_str. If the numeric part fails to parse it panics with the variable name, raw value, and underlying parse error. It also enforces an optional maximum afterwards.","triggerScenarios":"Setting a duration env var (e.g. cache/connect timeouts) to a value whose numeric component is unparseable — 'abc s', '5minutes' with an unsupported unit path, or trailing whitespace/quotes.","commonSituations":"Hand-edited deployment configs using human-friendly values ('5 min', '30seconds') instead of the supported numeric+unit format; CI secrets with stray spaces or newline characters.","solutions":["Set the value as <number><supported unit> matching what the code strips (e.g. '60s', '10m'), or a bare number if unitless is accepted","Trim whitespace and remove surrounding quotes from the env value","Unset the variable to use the built-in default"],"exampleFix":"// before\nCUBEJS_REFRESH_WIFI=every few minutes\n// after\nCUBEJS_REFRESH_WIFI=300s","handlingStrategy":"validation","validationCode":"// Validate duration env vars: number + supported unit\ncheck_duration() {\n  echo \"$1\" | grep -Eq '^[0-9]+(s|m|h|ms)?$' || { echo \"invalid duration '$1' (expected e.g. 30s, 5m)\"; exit 1; }\n}\n[ -n \"$CUBEJS_REFRESH_WIFI\" ] && check_duration \"$CUBEJS_REFRESH_WIFI\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Express durations as plain numbers with a single unit suffix (300s, 5m, 1h)","Avoid prose values like 'every few minutes' in env files","Watch for CI-injected trailing whitespace/newlines in secrets and env vars","Document the exact accepted formats next to each duration variable"],"tags":["rust","panic","environment-variable","duration","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"}