{"record":{"id":"a7a0c4049d81d926","repo":"pola-rs/polars","slug":"invalid-value-for-name-x","errorCode":null,"errorMessage":"invalid value for {NAME}: {x}","messagePattern":"invalid value for (.+?): (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-core/src/chunked_array/ops/gather.rs","lineNumber":463,"sourceCode":"\nimpl<I: AsRef<[IdxSize]> + ?Sized> ChunkTakeUnchecked<I> for ListChunked {\n    unsafe fn take_unchecked(&self, indices: &I) -> Self {\n        let idx = IdxCa::mmap_slice(PlSmallStr::EMPTY, indices.as_ref());\n        self.take_unchecked(&idx)\n    }\n}\n\nfn should_rechunk(n_values: usize, n_indices: usize) -> bool {\n    n_indices > 0 && { (n_values / n_indices) > gather_ratio() }\n}\n\nfn gather_ratio() -> usize {\n    return *GATHER_RECHUNK_RATIO.get_or_init(|| {\n        const NAME: &str = \"POLARS_GATHER_RECHUNK_RATIO\";\n        std::env::var(NAME)\n            .map(|x| {\n                x.parse::<usize>()\n                    .unwrap_or_else(|_| panic!(\"invalid value for {NAME}: {x}\"))\n            })\n            .unwrap_or(const { 64 })\n    });\n\n    static GATHER_RECHUNK_RATIO: OnceLock<usize> = OnceLock::new();\n}\n","sourceCodeStart":445,"sourceCodeEnd":470,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-core/src/chunked_array/ops/gather.rs#L445-L470","documentation":"The gather/rechunk ratio used internally by gather operations is configurable through the POLARS_GATHER_RECHUNK_RATIO environment variable and must parse as a usize. If the variable is set to something unparseable (e.g. \"64.0\", \"fast\", empty string), gather_ratio panics with this message instead of silently falling back.","triggerScenarios":"Setting env var POLARS_GATHER_RECHUNK_RATIO to a non-integer string, then running any operation that triggers gather (take/join/groupby internals that call should_rechunk).","commonSituations":"Typos in tuning configs, copying a fractional or suffixed value ('0.5', '64M'), or exporting the variable empty in a shell profile.","solutions":["Set POLARS_GATHER_RECHUNK_RATIO to a plain positive integer, e.g. 64","Unset the variable (delete/export -n) to fall back to the built-in default of 64","Fix the value in whichever startup script/CI config exports it"],"exampleFix":"// before\nexport POLARS_GATHER_RECHUNK_RATIO=0.5   # panics\n// after\nexport POLARS_GATHER_RECHUNK_RATIO=32","handlingStrategy":"validation","validationCode":"if let Ok(v) = std::env::var(\"POLARS_GATHER_RECHUNK_RATIO\") {\n    if v.parse::<usize>().is_err() { return Err(format!(\"POLARS_GATHER_RECHUNK_RATIO must be a usize, got {v}\")); }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate tuning env vars at startup with a fail-fast check","Never set fractional or suffixed values ('0.5', '64M')","Unset the variable to use the default of 64"],"tags":["rust","polars","environment-variable","tuning"],"backgroundTag":"invalid-env-var-value","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}