{"record":{"id":"343524367d32c374","repo":"pola-rs/polars","slug":"invalid-value-for-polars-num-readers-pre-init-x","errorCode":null,"errorMessage":"invalid value for POLARS_NUM_READERS_PRE_INIT: {x}","messagePattern":"invalid value for POLARS_NUM_READERS_PRE_INIT: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-stream/src/nodes/io_sources/multi_scan/functions/mod.rs","lineNumber":23,"sourceCode":"use polars_io::cloud::CloudOptions;\nuse polars_io::cloud::concurrency_config::FetchConfig;\nuse polars_io::metrics::IOMetrics;\nuse polars_io::utils::byte_source::{ByteSource, DynByteSourceBuilder};\nuse polars_io::utils::compression::SupportedCompression;\nuse polars_plan::dsl::ScanSource;\nuse polars_utils::slice_enum::Slice;\n\npub mod resolve_projections;\npub mod resolve_slice;\n\npub fn calc_n_readers_pre_init(\n    num_pipelines: usize,\n    num_sources: usize,\n    pre_slice: Option<&Slice>,\n) -> usize {\n    if let Ok(v) = std::env::var(\"POLARS_NUM_READERS_PRE_INIT\").map(|x| {\n        x.parse::<NonZeroUsize>()\n            .unwrap_or_else(|_| panic!(\"invalid value for POLARS_NUM_READERS_PRE_INIT: {x}\"))\n            .get()\n    }) {\n        return v;\n    }\n\n    let max_files_with_slice = match pre_slice {\n        // Calculate the max number of files assuming 1 row per file.\n        Some(v @ Slice::Positive { .. }) => v.end_position().max(1),\n        Some(Slice::Negative { .. }) | None => usize::MAX,\n    };\n\n    // Set this generously high, there are users who scan 10,000's of small files from the cloud.\n    num_pipelines\n        .saturating_add(3)\n        .min(max_files_with_slice)\n        .min(num_sources)\n        .clamp(1, 128)\n}","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/pola-rs/polars/blob/9b5d73fd00236295624374b075d16b1fe6ec6df9/crates/polars-stream/src/nodes/io_sources/multi_scan/functions/mod.rs#L5-L41","documentation":"Panic in calc_n_readers_pre_init: POLARS_NUM_READERS_PRE_INIT was set but cannot be parsed as a usize. The env var overrides how many multi-scan readers are initialized up front, so the unparsable value {x} panics before scan setup.","triggerScenarios":"Invalid value in POLARS_NUM_READERS_PRE_INIT.","commonSituations":"See trigger scenarios.","solutions":["Set POLARS_NUM_READERS_PRE_INIT to a positive integer or unset it."],"exampleFix":"export POLARS_NUM_READERS_PRE_INIT=2","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9b5d73fd00236295624374b075d16b1fe6ec6df9","analyzedAt":"2026-08-19T12:15:06.350Z","contentChangedAt":"2026-08-19T12:15:06.350Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}