pola-rs/polars · error

invalid value for POLARS_CSV_CHUNK_PREFETCH_LIMIT: {x}

Error message

invalid value for POLARS_CSV_CHUNK_PREFETCH_LIMIT: {x}

What it means

Panic in CsvReaderBuilder::set_execution_state: POLARS_CSV_CHUNK_PREFETCH_LIMIT was set but failed to parse as a NonZeroUsize (non-numeric, zero, or overflow). The CSV chunk prefetch pipeline defaults are replaced by this env var, so an invalid value aborts streaming setup with the raw string {x}.

Source

Thrown at crates/polars-stream/src/nodes/io_sources/csv/builder.rs:59

    fn reader_capabilities(&self) -> ReaderCapabilities {
        use ReaderCapabilities as RC;

        if self.options.parse_options.comment_prefix.is_some() {
            RC::empty()
        } else {
            RC::PRE_SLICE
        }
    }

    fn set_execution_state(&self, execution_state: &crate::execute::StreamingExecutionState) {
        // The maximum number of chunks actively being prefetched at any given point in time.
        let prefetch_limit = std::env::var("POLARS_CSV_CHUNK_PREFETCH_LIMIT")
            .map(|x| {
                x.parse::<NonZeroUsize>()
                    .ok()
                    .unwrap_or_else(|| {
                        panic!("invalid value for POLARS_CSV_CHUNK_PREFETCH_LIMIT: {x}")
                    })
                    .get()
            })
            .unwrap_or(execution_state.num_pipelines.saturating_mul(2))
            .max(1);

        self.prefetch_limit.store(prefetch_limit);

        if config::verbose() {
            eprintln!(
                "[CsvReaderBuilder]: prefetch_limit: {}",
                self.prefetch_limit.load()
            );
        }

        self.prefetch_semaphore
            .set(Arc::new(tokio::sync::Semaphore::new(prefetch_limit)))
            .unwrap()

View on GitHub (pinned to 9b5d73fd00)

Solutions

  1. Set POLARS_CSV_CHUNK_PREFETCH_LIMIT to a positive integer or unset it.

Example fix

export POLARS_CSV_CHUNK_PREFETCH_LIMIT=4
Defensive patterns

Strategy: validation

When it happens

Trigger: Invalid (unparseable) value in POLARS_CSV_CHUNK_PREFETCH_LIMIT.

Common situations: See trigger scenarios.


AI-assisted analysis of pola-rs/polars@9b5d73fd00 (2026-08-19). Data as JSON: /api/errors/c23b5807e88740d3. Report an issue: GitHub.