pola-rs/polars · error
invalid value for POLARS_PARTITIONED_UPLOAD_CHUNK_SIZE
Error message
invalid value for POLARS_PARTITIONED_UPLOAD_CHUNK_SIZE: {s} What it means
This panic fires when the environment variable POLARS_PARTITIONED_UPLOAD_CHUNK_SIZE is set but does not parse as a non-zero usize. It configures the per-partition upload chunk size used by Polars' partitioned cloud writers. Since it is treated as mandatory configuration whenever present, an invalid value aborts the process rather than falling back to a default.
Solutions
- Set the variable to a plain positive integer (>= 1) or remove it to use the default
- Check for whitespace or invisible characters in the shell/CI environment
- If you intended to change chunk size for non-partitioned writes, use POLARS_UPLOAD_CHUNK_SIZE instead
Example fix
// before POLARS_PARTITIONED_UPLOAD_CHUNK_SIZE=0 // after POLARS_PARTITIONED_UPLOAD_CHUNK_SIZE=1048576
Defensive patterns
Strategy: validation
Validate before calling
const v = process.env.POLARS_PARTITIONED_UPLOAD_CHUNK_SIZE;
if (v !== undefined && !/^[0-9]+$/.test(v.trim())) throw new Error(`POLARS_PARTITIONED_UPLOAD_CHUNK_SIZE must be a positive integer, got: ${v}`); Type guard
function isValidChunkSize(v) { return typeof v === 'string' && /^[0-9]+$/.test(v.trim()) && parseInt(v, 10) > 0; } Try / catch
// panic is not catchable; sanitize env before spawning the process const raw = process.env.POLARS_PARTITIONED_UPLOAD_CHUNK_SIZE; if (raw && !/^\d+$/.test(raw.trim())) delete process.env.POLARS_PARTITIONED_UPLOAD_CHUNK_SIZE;
Prevention
- Use positive integers only; no units or decimals
- Remove the variable rather than setting 0
- Keep partitioned and non-partitioned vars distinct in config files
- Audit .env and container env for stale values
When it happens
Trigger: export POLARS_PARTITIONED_UPLOAD_CHUNK_SIZE=0, or any non-integer string like 'ten', '2.5', '-1', or an empty value; the panic occurs in env_partitioned_upload_chunk_size when a partitioned cloud writer reads its config.
Common situations: Users tuning partitioned writes to cloud storage (S3/GCS/Azure) mistyping the value; confusing this var with a byte-size var and appending units; zero value under the misconception it disables partitioning.
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_UPLOAD_CHUNK_SIZE
- 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/bc746701521ac497.
Report an issue: GitHub.
Appendix: source
Thrown at crates/polars-io/src/configs.rs:16
use std::num::NonZeroUsize;
use std::sync::LazyLock;
pub fn env_upload_chunk_size() -> Option<NonZeroUsize> {
std::env::var("POLARS_UPLOAD_CHUNK_SIZE").ok().map(|s| {
s.parse::<NonZeroUsize>()
.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}")View on GitHub (pinned to fe841f959e)