{"record":{"id":"9140a7ea2a9a7774","repo":"pola-rs/polars","slug":"invalid-value-for-polars-lines-chunk-prefetch-limi","errorCode":null,"errorMessage":"invalid value for POLARS_LINES_CHUNK_PREFETCH_LIMIT: {x}","messagePattern":"invalid value for POLARS_LINES_CHUNK_PREFETCH_LIMIT: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-stream/src/nodes/io_sources/lines.rs","lineNumber":54,"sourceCode":"}\n\nimpl FileReaderBuilder for LineReaderBuilder {\n    fn reader_name(&self) -> &str {\n        \"line\"\n    }\n\n    fn reader_capabilities(&self) -> ReaderCapabilities {\n        ndjson_reader_capabilities()\n    }\n\n    fn set_execution_state(&self, execution_state: &crate::execute::StreamingExecutionState) {\n        // The maximum number of chunks actively being prefetched at any point in time.\n        let prefetch_limit = std::env::var(\"POLARS_LINES_CHUNK_PREFETCH_LIMIT\")\n            .map(|x| {\n                x.parse::<NonZeroUsize>()\n                    .ok()\n                    .unwrap_or_else(|| {\n                        panic!(\"invalid value for POLARS_LINES_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                \"[LineReaderBuilder]: 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":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-stream/src/nodes/io_sources/lines.rs#L36-L72","documentation":"Polars panics when POLARS_LINES_CHUNK_PREFETCH_LIMIT is set but not a valid non-zero usize. The lines (text) source reads it in set_execution_state to bound how many chunks are prefetched concurrently; the default is 2x the number of pipelines, clamped to at least 1.","triggerScenarios":"Reading plain-text/lines files (read_lines / streaming lines source) with the env var set to '', '0', 'abc', or a number larger than usize::MAX.","commonSituations":"A leftover export from tuning experiments, an empty value in a Kubernetes manifest env entry, or a fractional value like '2.5'.","solutions":["Set the variable to a plain positive integer (e.g. 8).","Unset it to get the default 2*num_pipelines prefetch limit.","Search dotfiles and deployment manifests for stale/empty definitions of this variable."],"exampleFix":"// before\nPOLARS_LINES_CHUNK_PREFETCH_LIMIT=0\n// after\nPOLARS_LINES_CHUNK_PREFETCH_LIMIT=8  # or unset","handlingStrategy":"validation","validationCode":"const v = process.env.POLARS_LINES_CHUNK_PREFETCH_LIMIT;\nif (v !== undefined && (!/^\\d+$/.test(v.trim()) || parseInt(v, 10) === 0)) {\n  throw new Error(`POLARS_LINES_CHUNK_PREFETCH_LIMIT must be a positive integer, got: '${v}'`);\n}","typeGuard":"function isValidPrefetchLimit(v) { return v === undefined || (/^\\d+$/.test(v.trim()) && Number(v.trim()) > 0); }","tryCatchPattern":"try {\n  runLinesScan();\n} catch (e) {\n  if (String(e).includes('POLARS_LINES_CHUNK_PREFETCH_LIMIT')) {\n    delete process.env.POLARS_LINES_CHUNK_PREFETCH_LIMIT;\n    runLinesScan();\n  } else throw e;\n}","preventionTips":["Treat 0 and empty string as invalid — unset instead.","Avoid fractional values; the parser accepts usize only.","Audit CI env blocks where this variable may be exported empty."],"tags":["rust","env-var","config"],"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"}