{"record":{"id":"c23b5807e88740d3","repo":"pola-rs/polars","slug":"invalid-value-for-polars-csv-chunk-prefetch-limit","errorCode":null,"errorMessage":"invalid value for POLARS_CSV_CHUNK_PREFETCH_LIMIT: {x}","messagePattern":"invalid value for POLARS_CSV_CHUNK_PREFETCH_LIMIT: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-stream/src/nodes/io_sources/csv/builder.rs","lineNumber":59,"sourceCode":"\n    fn reader_capabilities(&self) -> ReaderCapabilities {\n        use ReaderCapabilities as RC;\n\n        if self.options.parse_options.comment_prefix.is_some() {\n            RC::empty()\n        } else {\n            RC::PRE_SLICE\n        }\n    }\n\n    fn set_execution_state(&self, execution_state: &crate::execute::StreamingExecutionState) {\n        // The maximum number of chunks actively being prefetched at any given point in time.\n        let prefetch_limit = std::env::var(\"POLARS_CSV_CHUNK_PREFETCH_LIMIT\")\n            .map(|x| {\n                x.parse::<NonZeroUsize>()\n                    .ok()\n                    .unwrap_or_else(|| {\n                        panic!(\"invalid value for POLARS_CSV_CHUNK_PREFETCH_LIMIT: {x}\")\n                    })\n                    .get()\n            })\n            .unwrap_or(execution_state.num_pipelines.saturating_mul(2))\n            .max(1);\n\n        self.prefetch_limit.store(prefetch_limit);\n\n        if config::verbose() {\n            eprintln!(\n                \"[CsvReaderBuilder]: prefetch_limit: {}\",\n                self.prefetch_limit.load()\n            );\n        }\n\n        self.prefetch_semaphore\n            .set(Arc::new(tokio::sync::Semaphore::new(prefetch_limit)))\n            .unwrap()","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-stream/src/nodes/io_sources/csv/builder.rs#L41-L77","documentation":"POLARS_CSV_CHUNK_PREFETCH_LIMIT caps how many CSV chunks may be prefetched concurrently during streaming CSV scans. If set and not parseable as a non-zero usize, Polars panics while building the CSV source (in set_execution_state).","triggerScenarios":"Setting POLARS_CSV_CHUNK_PREFETCH_LIMIT to '0', 'none', '', or any non-positive-integer string, then scanning a CSV in the streaming engine (scan_csv/sink from CSV).","commonSituations":"Tuning IO concurrency for CSV ingestion; CI matrix env vars with a 'disable' placeholder value; unit-suffixed numbers.","solutions":["Set a positive integer, e.g. export POLARS_CSV_CHUNK_PREFETCH_LIMIT=8.","Unset it to default to num_pipelines * 2 (minimum 1).","Grep shell init files and deployment manifests for the malformed value."],"exampleFix":"# before\nexport POLARS_CSV_CHUNK_PREFETCH_LIMIT=none\n# after\nexport POLARS_CSV_CHUNK_PREFETCH_LIMIT=8","handlingStrategy":"validation","validationCode":"import os\nv = os.environ.get(\"POLARS_CSV_CHUNK_PREFETCH_LIMIT\")\nif v is not None:\n    assert v.isdigit() and int(v) > 0, f\"POLARS_CSV_CHUNK_PREFETCH_LIMIT must be positive int, got {v!r}\"","typeGuard":"def is_positive_int(s: str) -> bool:\n    return s.isdigit() and int(s) > 0","tryCatchPattern":"v = os.environ.get(\"POLARS_CSV_CHUNK_PREFETCH_LIMIT\", \"\")\nif v and not (v.isdigit() and int(v) > 0):\n    os.environ.pop(\"POLARS_CSV_CHUNK_PREFETCH_LIMIT\", None)  # default: num_pipelines*2","preventionTips":["Replace 'disable'/'none' placeholders with unset in CI matrices","Keep the value >= 1; defaults already enforce a floor","Audit shared tuning scripts for this var","Validate POLARS_* env at job startup"],"tags":["environment-variable","panic","csv","configuration"],"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"}