{"record":{"id":"7212efa901644332","repo":"pola-rs/polars","slug":"invalid-value-for-polars-cloud-writer-coalesce-run","errorCode":null,"errorMessage":"invalid value for POLARS_CLOUD_WRITER_COALESCE_RUN_LENGTH: {s}","messagePattern":"invalid value for POLARS_CLOUD_WRITER_COALESCE_RUN_LENGTH: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-io/src/configs.rs","lineNumber":53,"sourceCode":"            })\n        })\n}\n\n/// Runs of this many values whose total bytes are <= `copy_buffer_reserve_size` will be copied into\n/// a single contiguous chunk.\npub(crate) fn cloud_writer_coalesce_run_length() -> usize {\n    return *COALESCE_RUN_LENGTH;\n\n    static COALESCE_RUN_LENGTH: LazyLock<usize> = LazyLock::new(|| {\n        let mut v: usize = 64;\n\n        if let Ok(s) = std::env::var(\"POLARS_CLOUD_WRITER_COALESCE_RUN_LENGTH\") {\n            v = s\n                .parse::<usize>()\n                .ok()\n                .filter(|x| *x >= 2)\n                .unwrap_or_else(|| {\n                    panic!(\"invalid value for POLARS_CLOUD_WRITER_COALESCE_RUN_LENGTH: {s}\")\n                })\n        }\n\n        if polars_core::config::verbose() {\n            eprintln!(\"cloud_writer coalesce_run_length: {v}\")\n        }\n\n        v\n    });\n}\n\npub(crate) fn cloud_writer_copy_buffer_size() -> NonZeroUsize {\n    return *COPY_BUFFER_SIZE;\n\n    static COPY_BUFFER_SIZE: LazyLock<NonZeroUsize> = LazyLock::new(|| {\n        let mut v: NonZeroUsize = const { NonZeroUsize::new(16 * 1024 * 1024).unwrap() };\n\n        if let Ok(s) = std::env::var(\"POLARS_CLOUD_WRITER_COPY_BUFFER_SIZE\") {","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-io/src/configs.rs#L35-L71","documentation":"This panic fires when POLARS_CLOUD_WRITER_COALESCE_RUN_LENGTH is set to a value that either fails usize parsing or is less than 2. The variable controls how many consecutive runs of values the cloud writer coalesces into one contiguous chunk. Unlike a simple parse, this function also filters out values below 2, so both non-numeric and too-small values trigger the panic.","triggerScenarios":"export POLARS_CLOUD_WRITER_COALESCE_RUN_LENGTH=1 (rejected by the *x >= 2 filter), 0, 'abc', '2.5', or negative numbers; the panic occurs in cloud_writer_coalesce_run_length when a cloud writer buffers data (invoked via BytesBufferer/push_owned).","commonSituations":"Users experimenting with coalescing set the minimum sensible value as 1, not knowing the hard floor is 2; typos; leftover experimental settings in .env files.","solutions":["Set the variable to an integer >= 2 (e.g. 64) or unset it for the default","If you intended to disable coalescing, remove the variable rather than setting it to 0 or 1","Enable Polars verbose logging (POLARS_VERBOSE=1) to confirm the accepted value: it prints 'cloud_writer coalesce_run_length: <v>'"],"exampleFix":"// before\nPOLARS_CLOUD_WRITER_COALESCE_RUN_LENGTH=1\n// after\nPOLARS_CLOUD_WRITER_COALESCE_RUN_LENGTH=32","handlingStrategy":"validation","validationCode":"const v = process.env.POLARS_CLOUD_WRITER_COALESCE_RUN_LENGTH;\nif (v !== undefined && !/^[0-9]+$/.test(v.trim())) throw new Error('must be an integer');\nif (v !== undefined && parseInt(v, 10) < 2) throw new Error('POLARS_CLOUD_WRITER_COALESCE_RUN_LENGTH must be >= 2');","typeGuard":"function isValidCoalesceRunLength(v) { const n = parseInt(v, 10); return typeof v === 'string' && /^[0-9]+$/.test(v.trim()) && n >= 2; }","tryCatchPattern":"// enforce the >= 2 floor before launch\nconst n = parseInt(process.env.POLARS_CLOUD_WRITER_COALESCE_RUN_LENGTH ?? '2', 10);\nif (!Number.isInteger(n) || n < 2) { delete process.env.POLARS_CLOUD_WRITER_COALESCE_RUN_LENGTH; }","preventionTips":["Remember the minimum accepted value is 2, not 1","Unset the variable to disable tuning rather than setting 0/1","Enable POLARS_VERBOSE=1 to confirm resolved values","Keep experimental tuning values out of committed .env files"],"tags":["env-var","configuration","panic","cloud-writer"],"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"}