pola-rs/polars · error
invalid value for POLARS_UPLOAD_CONCURRENCY
Error message
invalid value for POLARS_UPLOAD_CONCURRENCY: {s} What it means
This panic occurs when POLARS_UPLOAD_CONCURRENCY is set to something that is not a non-zero usize. The variable caps the number of concurrent upload tasks inside a single cloud writer; env_upload_concurrency parses it eagerly and panics on failure. Polars assumes any present value is intentional and valid, so no fallback is applied.
Solutions
- Set POLARS_UPLOAD_CONCURRENCY to a positive integer (e.g. 8) or unset it for the default
- Ensure the value has no units, decimals, or surrounding whitespace
- Inspect the runtime environment (`env | grep POLARS_UPLOAD_CONCURRENCY`) inside the actual process context (container/CI), not just your shell
Example fix
// before export POLARS_UPLOAD_CONCURRENCY=0 // after export POLARS_UPLOAD_CONCURRENCY=8
Defensive patterns
Strategy: validation
Validate before calling
const v = process.env.POLARS_UPLOAD_CONCURRENCY;
if (v !== undefined && !/^[0-9]+$/.test(v.trim())) throw new Error(`POLARS_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
// pre-launch validation; panics abort the process so catch-and-fix the env
if (!isValidConcurrency(process.env.POLARS_UPLOAD_CONCURRENCY ?? '1')) { console.error('POLARS_UPLOAD_CONCURRENCY must be >= 1 integer'); process.exit(2); } Prevention
- Never set 0 to 'disable' concurrency - unset instead
- Validate env in entrypoint scripts
- Match the exact variable name (upload vs partitioned upload)
- Document accepted formats in team runbooks
When it happens
Trigger: export POLARS_UPLOAD_CONCURRENCY=0 (zero is rejected by NonZeroUsize), POLARS_UPLOAD_CONCURRENCY=abc, '3.0', '-4', or an empty string; the panic fires when a cloud writer initializes and reads this setting.
Common situations: Attempts to 'disable' concurrency by setting 0; decimal values copied from YAML/JSON configs; typos in automation scripts; container images with a stale invalid value baked into the environment.
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
- invalid value for POLARS_PARTITIONED_UPLOAD_CONCURRENCY
- in-flight byte budget init must be larger than the…
- integer
- integer
- invalid `POLARS_MAX_CACHED_METADATA_SCANS` value
AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18).
Data as JSON: /api/errors/4473dae7f2f0b34a.
Report an issue: GitHub.
Appendix: source
Thrown at crates/polars-io/src/configs.rs:25
.unwrap_or_else(|_| panic!("invalid value for POLARS_UPLOAD_CHUNK_SIZE: {s}"))
})
}
pub fn env_partitioned_upload_chunk_size() -> Option<NonZeroUsize> {
std::env::var("POLARS_PARTITIONED_UPLOAD_CHUNK_SIZE")
.ok()
.map(|s| {
s.parse::<NonZeroUsize>().unwrap_or_else(|_| {
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;
View on GitHub (pinned to fe841f959e)