{"record":{"id":"c1e24c29c067ef80","repo":"pola-rs/polars","slug":"invalid-value-for-polars-python-scan-resolve-threa","errorCode":null,"errorMessage":"invalid value for POLARS_PYTHON_SCAN_RESOLVE_THREADS: {x}","messagePattern":"invalid value for POLARS_PYTHON_SCAN_RESOLVE_THREADS: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-plan/src/plans/optimizer/expand_datasets.rs","lineNumber":513,"sourceCode":"        pyo3::IntoPyObject::into_pyobject(&self.0, py)\n    }\n}\n\n#[cfg(feature = \"python\")]\nimpl PyScanResolveThreadPool {\n    pub fn new() -> Self {\n        use std::num::NonZeroUsize;\n        use std::sync::LazyLock;\n\n        use pyo3::types::PyAnyMethods;\n        use pyo3::{Py, PyAny, PyResult, Python};\n\n        Python::attach(|py| {\n            let num_threads =\n                std::env::var(\"POLARS_PYTHON_SCAN_RESOLVE_THREADS\").map_or(128, |x| {\n                    x.parse::<NonZeroUsize>()\n                        .unwrap_or_else(|_| {\n                            panic!(\"invalid value for POLARS_PYTHON_SCAN_RESOLVE_THREADS: {x}\")\n                        })\n                        .get()\n                });\n\n            if polars_config::config().verbose() {\n                eprintln!(\"python scan_resolve_threadpool threads: {num_threads}\")\n            }\n\n            if LazyLock::get(&PY_SCAN_RESOLVE_THREADPOOL_CLS).is_none() {\n                py.detach(|| LazyLock::force(&PY_SCAN_RESOLVE_THREADPOOL_CLS));\n            }\n\n            return Self(\n                PY_SCAN_RESOLVE_THREADPOOL_CLS\n                    .bind(py)\n                    .call1((num_threads,))\n                    .map(|x| x.unbind())\n                    .unwrap(),","sourceCodeStart":495,"sourceCodeEnd":531,"githubUrl":"https://github.com/pola-rs/polars/blob/fc24390824009e8fc5b7870e256273c1b140a019/crates/polars-plan/src/plans/optimizer/expand_datasets.rs#L495-L531","documentation":"PyScanResolveThreadPool::new reads POLARS_PYTHON_SCAN_RESOLVE_THREADS and parses it as NonZeroUsize; an unparseable or zero value makes the unwrap_or_else panic with this message naming the raw value. Set the env var to a positive integer or unset it for the default (128).","triggerScenarios":"This panic/expect fires when execution reaches an unguarded state described by: \"invalid value for POLARS_PYTHON_SCAN_RESOLVE_THREADS: {x}\". Typical triggers: unsupported dtype or feature-gated code path reached at runtime, invalid user input or environment variable value, calling API methods in the wrong order or on mismatched types, or data (lengths, offsets, ranges) violating the function's preconditions.","commonSituations":"Encountered when input data or configuration does not meet the preconditions of the throwing code path (\"invalid value for POLARS_PYTHON_SCAN_RESOLVE_THREADS: {x}\"). Common cases: missing Cargo feature flags, mismatched dtypes/lengths between arrays or series, out-of-range temporal values, malformed environment variables, or operations on unsupported/complex nested types.","solutions":["Set POLARS_PYTHON_SCAN_RESOLVE_THREADS to a valid positive integer.","Unset the variable to use the default thread count."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fc24390824009e8fc5b7870e256273c1b140a019","analyzedAt":"2026-08-19T12:15:06.350Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}