pola-rs/polars · error

invalid value for POLARS_PARTITIONED_UPLOAD_CONCURRENCY

Error message

invalid value for POLARS_PARTITIONED_UPLOAD_CONCURRENCY: {s}

What it means

This panic is raised when POLARS_PARTITIONED_UPLOAD_CONCURRENCY is present but cannot be parsed as a non-zero usize. It limits concurrent tasks per partition within Polars' partitioned cloud writers. An unparseable or zero value panics because the env var, when set, is treated as authoritative configuration.

Solutions

  1. Set the variable to a plain positive integer or delete it to use the default
  2. Cross-check that you did not mean POLARS_UPLOAD_CONCURRENCY (non-partitioned variant)
  3. Validate numeric env vars in CI before deploying (e.g. a regex check ^[1-9][0-9]*$)

Example fix

// before
POLARS_PARTITIONED_UPLOAD_CONCURRENCY=1.5
// after
POLARS_PARTITIONED_UPLOAD_CONCURRENCY=4
Defensive patterns

Strategy: validation

Validate before calling

const v = process.env.POLARS_PARTITIONED_UPLOAD_CONCURRENCY;
if (v !== undefined && !/^[0-9]+$/.test(v.trim())) throw new Error(`POLARS_PARTITIONED_UPLOAD_CONCURRENCY must be a positive integer, got: ${v}`);

Type guard

function isValidConcurrency(v) { return typeof v === 'string' && /^[1-9][0-9]*$/.test(v.trim()); }

Try / catch

// validate before process start; panic is fatal
const raw = process.env.POLARS_PARTITIONED_UPLOAD_CONCURRENCY;
if (raw && !/^\d+$/.test(raw.trim())) { console.error('invalid POLARS_PARTITIONED_UPLOAD_CONCURRENCY'); process.exit(2); }

Prevention

When it happens

Trigger: export POLARS_PARTITIONED_UPLOAD_CONCURRENCY=0, 'abc', '1.5', '-2', or empty; triggered when a partitioned cloud writer reads its concurrency settings via env_partitioned_upload_concurrency.

Common situations: Misunderstanding that 0 means unlimited; copying values with unit suffixes; drift between documentation and accepted format; Kubernetes ConfigMap injecting an empty string.

Understand the failure class

Background: "is not a valid" / "Invalid ... value" environment variable errors: how libraries validate env vars and what to do when they reject yours — this error's family across 48 libraries.

Related errors


AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18). Data as JSON: /api/errors/05ac03f8bc07af9b. Report an issue: GitHub.

Appendix: source

Thrown at crates/polars-io/src/configs.rs:34

                panic!("invalid value for POLARS_PARTITIONED_UPLOAD_CHUNK_SIZE: {s}")
            })
        })
}

/// Max concurrent tasks within a single cloud writer.
pub fn env_upload_concurrency() -> Option<NonZeroUsize> {
    std::env::var("POLARS_UPLOAD_CONCURRENCY").ok().map(|s| {
        s.parse::<NonZeroUsize>()
            .unwrap_or_else(|_| panic!("invalid value for POLARS_UPLOAD_CONCURRENCY: {s}"))
    })
}

pub fn env_partitioned_upload_concurrency() -> Option<NonZeroUsize> {
    std::env::var("POLARS_PARTITIONED_UPLOAD_CONCURRENCY")
        .ok()
        .map(|s| {
            s.parse::<NonZeroUsize>().unwrap_or_else(|_| {
                panic!("invalid value for POLARS_PARTITIONED_UPLOAD_CONCURRENCY: {s}")
            })
        })
}

/// Runs of this many values whose total bytes are <= `copy_buffer_reserve_size` will be copied into
/// a single contiguous chunk.
pub(crate) fn cloud_writer_coalesce_run_length() -> usize {
    return *COALESCE_RUN_LENGTH;

    static COALESCE_RUN_LENGTH: LazyLock<usize> = LazyLock::new(|| {
        let mut v: usize = 64;

        if let Ok(s) = std::env::var("POLARS_CLOUD_WRITER_COALESCE_RUN_LENGTH") {
            v = s
                .parse::<usize>()
                .ok()
                .filter(|x| *x >= 2)
                .unwrap_or_else(|| {

View on GitHub (pinned to fe841f959e)