{"record":{"id":"d1e0c3f1265fc2e2","repo":"pola-rs/polars","slug":"invalid-value-for-polars-upload-chunk-size-s","errorCode":null,"errorMessage":"invalid value for POLARS_UPLOAD_CHUNK_SIZE: {s}","messagePattern":"invalid value for POLARS_UPLOAD_CHUNK_SIZE: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-io/src/configs.rs","lineNumber":7,"sourceCode":"use std::num::NonZeroUsize;\nuse std::sync::LazyLock;\n\npub fn env_upload_chunk_size() -> Option<NonZeroUsize> {\n    std::env::var(\"POLARS_UPLOAD_CHUNK_SIZE\").ok().map(|s| {\n        s.parse::<NonZeroUsize>()\n            .unwrap_or_else(|_| panic!(\"invalid value for POLARS_UPLOAD_CHUNK_SIZE: {s}\"))\n    })\n}\n\npub fn env_partitioned_upload_chunk_size() -> Option<NonZeroUsize> {\n    std::env::var(\"POLARS_PARTITIONED_UPLOAD_CHUNK_SIZE\")\n        .ok()\n        .map(|s| {\n            s.parse::<NonZeroUsize>().unwrap_or_else(|_| {\n                panic!(\"invalid value for POLARS_PARTITIONED_UPLOAD_CHUNK_SIZE: {s}\")\n            })\n        })\n}\n\n/// Max concurrent tasks within a single cloud writer.\npub fn env_upload_concurrency() -> Option<NonZeroUsize> {\n    std::env::var(\"POLARS_UPLOAD_CONCURRENCY\").ok().map(|s| {\n        s.parse::<NonZeroUsize>()\n            .unwrap_or_else(|_| panic!(\"invalid value for POLARS_UPLOAD_CONCURRENCY: {s}\"))","sourceCodeStart":1,"sourceCodeEnd":25,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-io/src/configs.rs#L1-L25","documentation":"This is a panic (process abort) thrown when the environment variable POLARS_UPLOAD_CHUNK_SIZE is set but cannot be parsed as a non-zero usize. Polars reads this variable in env_upload_chunk_size to configure the upload chunk size for cloud writers. Any value that is empty, non-numeric, negative, or zero causes an immediate panic instead of returning an error, because the value is expected to be valid configuration.","triggerScenarios":"Setting POLARS_UPLOAD_CHUNK_SIZE to a value that fails NonZeroUsize::parse, e.g. export POLARS_UPLOAD_CHUNK_SIZE=0, POLARS_UPLOAD_CHUNK_SIZE=abc, POLARS_UPLOAD_CHUNK_SIZE=-100, POLARS_UPLOAD_CHUNK_SIZE=1e6, or POLARS_UPLOAD_CHUNK_SIZE=\" 1024\" (whitespace). The panic fires the first time env_upload_chunk_size is consulted during cloud/remote file IO.","commonSituations":"Copy-pasted config with a typo; setting the variable to 0 believing it means 'unlimited' or 'default'; adding unit suffixes like '4MB' or '1_000_000'; shell quoting whitespace; CI/CD templating that injects an empty string.","solutions":["Set POLARS_UPLOAD_CHUNK_SIZE to a plain positive integer (e.g. 8388608), or unset it entirely to use the built-in default","Verify the value parses: cargo eval or `echo $POLARS_UPLOAD_CHUNK_SIZE` and ensure it matches ^[0-9]+$ and is >= 1","Check CI/CD templating and .env files for empty or malformed values being injected into the variable"],"exampleFix":"// before\nexport POLARS_UPLOAD_CHUNK_SIZE=4MB\n// after\nexport POLARS_UPLOAD_CHUNK_SIZE=4194304","handlingStrategy":"validation","validationCode":"const v = process.env.POLARS_UPLOAD_CHUNK_SIZE;\nif (v !== undefined && !/^[0-9]+$/.test(v.trim())) throw new Error(`POLARS_UPLOAD_CHUNK_SIZE must be a positive integer, got: ${v}`);","typeGuard":"function isValidChunkSize(v) { return typeof v === 'string' && /^[0-9]+$/.test(v.trim()) && parseInt(v, 10) > 0; }","tryCatchPattern":"// panic cannot be caught from the host language; fix the env value before launch\ntry { runPolarsJob(); } catch (e) { if (/invalid value for POLARS_UPLOAD_CHUNK_SIZE/.test(String(e))) console.error('Fix POLARS_UPLOAD_CHUNK_SIZE: positive integer required'); throw e; }","preventionTips":["Only set the variable to plain positive integers in bytes","Unset the variable entirely if you want defaults","Validate numeric POLARS_* env vars in CI/deployment scripts","Avoid quoting or unit suffixes in shell exports"],"tags":["env-var","configuration","panic","polars"],"backgroundTag":"invalid-env-var-value","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}