{"record":{"id":"32a37755204199f0","repo":"pola-rs/polars","slug":"invalid-value-for-polars-cloud-writer-copy-buffer","errorCode":null,"errorMessage":"invalid value for POLARS_CLOUD_WRITER_COPY_BUFFER_SIZE: {s}","messagePattern":"invalid value for POLARS_CLOUD_WRITER_COPY_BUFFER_SIZE: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-io/src/configs.rs","lineNumber":73,"sourceCode":"        }\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\") {\n            v = s.parse::<NonZeroUsize>().unwrap_or_else(|_| {\n                panic!(\"invalid value for POLARS_CLOUD_WRITER_COPY_BUFFER_SIZE: {s}\")\n            })\n        }\n\n        if polars_core::config::verbose() {\n            eprintln!(\"cloud_writer copy_buffer_size: {v}\")\n        }\n\n        v\n    });\n}\n\n/// Tail size to speculatively fetch when reading file metadata from a cloud source. Sized\n/// generously as the cost of overfetching is low (extra KB) vs the cost of underfetching\n/// (extra round-trip).\npub const DEFAULT_CLOUD_FOOTER_READ_SIZE: usize = 256 * 1024;\n\n// Not cached - lookup cost is low compared to I/O, allows for testing.\npub fn cloud_footer_read_size() -> usize {","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-io/src/configs.rs#L55-L91","documentation":"This panic occurs when POLARS_CLOUD_WRITER_COPY_BUFFER_SIZE is set but does not parse as a non-zero usize. The variable overrides the copy buffer size (default 16 MiB) used by the cloud writer when copying data into contiguous buffers. The value is read once inside a LazyLock, so the panic happens on first access during writer construction.","triggerScenarios":"export POLARS_CLOUD_WRITER_COPY_BUFFER_SIZE=0, '16MB', '16*1024*1024', 'abc', or empty; triggered in cloud_writer_copy_buffer_size when the cloud writer is created (BytesBufferer::new).","commonSituations":"Appending unit suffixes like MB/GB out of habit; arithmetic expressions that shells do not evaluate; a container image with a malformed tuned value; mistaking it for a knob that accepts 0 to disable buffering.","solutions":["Set the variable to a plain positive integer of bytes (e.g. 33554432 for 32 MiB) or unset for the 16 MiB default","Compute byte values yourself before exporting (no expressions or units accepted)","Enable POLARS_VERBOSE=1 to see the resolved 'cloud_writer copy_buffer_size' at startup"],"exampleFix":"// before\nexport POLARS_CLOUD_WRITER_COPY_BUFFER_SIZE=32MB\n// after\nexport POLARS_CLOUD_WRITER_COPY_BUFFER_SIZE=33554432","handlingStrategy":"validation","validationCode":"const v = process.env.POLARS_CLOUD_WRITER_COPY_BUFFER_SIZE;\nif (v !== undefined && !/^[0-9]+$/.test(v.trim())) throw new Error(`POLARS_CLOUD_WRITER_COPY_BUFFER_SIZE must be a positive integer of bytes, got: ${v}`);","typeGuard":"function isValidByteSize(v) { return typeof v === 'string' && /^[1-9][0-9]*$/.test(v.trim()); }","tryCatchPattern":"// convert human sizes to bytes before export; reject anything else\nconst raw = process.env.POLARS_CLOUD_WRITER_COPY_BUFFER_SIZE;\nif (raw && !/^\\d+$/.test(raw.trim())) { console.error('use plain bytes, e.g. 33554432'); process.exit(2); }","preventionTips":["Always express the value in raw bytes - no MB/GB suffixes or arithmetic","Compute 32 * 1024 * 1024 in your shell before exporting","Unset for the 16 MiB default","Verify with POLARS_VERBOSE=1 at startup"],"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"}