{"record":{"id":"6647f48f373afb7c","repo":"pola-rs/polars","slug":"invalid-value-for-polars-io-sink-bytes-bufferer-config-v","errorCode":null,"errorMessage":"invalid value for POLARS_IO_SINK_BYTES_BUFFERER_CONFIG: {v}","messagePattern":"invalid value for POLARS_IO_SINK_BYTES_BUFFERER_CONFIG: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-stream/src/nodes/io_sinks/config.rs","lineNumber":123,"sourceCode":"\n    pub fn bytes_bufferer_config(&self) -> BytesBuffererConfig {\n        if let Ok(v) = std::env::var(\"POLARS_IO_SINK_BYTES_BUFFERER_CONFIG\") {\n            (|| {\n                let mut iter = v.split(',').map(|x| x.parse::<NonZeroUsize>().ok());\n                let mut n = || iter.next().flatten();\n\n                let ret = BytesBuffererConfig {\n                    target_size: n()?..=n()?,\n                    copy_buffer_reserve_size: n()?..=n()?,\n                };\n\n                let valid = ret.target_size.end() >= ret.target_size.start()\n                    && ret.copy_buffer_reserve_size.end() >= ret.copy_buffer_reserve_size.start();\n\n                (valid && iter.next().is_none()).then_some(ret)\n            })()\n            .unwrap_or_else(|| {\n                panic!(\"invalid value for POLARS_IO_SINK_BYTES_BUFFERER_CONFIG: {v}\")\n            })\n        } else if self.target.is_cloud_location() {\n            let cloud_upload_chunk_size = self\n                .cloud_upload_chunk_size()\n                .unwrap_or(DEFAULT_UPLOAD_CHUNK_SIZE);\n\n            BytesBuffererConfig {\n                target_size: cloud_upload_chunk_size..=cloud_upload_chunk_size,\n                copy_buffer_reserve_size: cloud_upload_chunk_size\n                    .div_ceil(const { NonZeroUsize::new(8).unwrap() })\n                    ..=cloud_upload_chunk_size,\n            }\n        } else {\n            const {\n                BytesBuffererConfig {\n                    target_size: NonZeroUsize::new(8192).unwrap()..=NonZeroUsize::MAX,\n                    copy_buffer_reserve_size: NonZeroUsize::new(8192).unwrap()..=NonZeroUsize::MAX,\n                }","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-stream/src/nodes/io_sinks/config.rs#L105-L141","documentation":"POLARS_IO_SINK_BYTES_BUFFERER_CONFIG is an optional env var carrying a structured size config (target size range and copy-buffer reserve) for sink byte buffering. Polars parses it into a validated struct; if the string is present but malformed, inconsistent (end < start), has trailing tokens, or reserves are inconsistent, it panics.","triggerScenarios":"Setting POLARS_IO_SINK_BYTES_BUFFERER_CONFIG to a malformed tuple/string and starting any file sink (single file or partitioned) via bytes_bufferer_config; the parse must yield valid ordering (end >= start for both ranges) and consume the entire value.","commonSituations":"Copy-pasting an internal debug config string with wrong separators or order-swapped ranges; partial truncation of a long env value; guessing the format instead of the documented one.","solutions":["Correct the value so both ranges satisfy start <= end and the whole string is consumed by the parser.","Unset POLARS_IO_SINK_BYTES_BUFFERER_CONFIG to use built-in defaults.","If tuning upload chunking, adjust POLARS_IO_SINK cloud upload chunk settings instead of hand-crafting this config."],"exampleFix":"# before (truncated / invalid)\nexport POLARS_IO_SINK_BYTES_BUFFERER_CONFIG=\"(1..0, 2..3\"\n# after\nunset POLARS_IO_SINK_BYTES_BUFFERER_CONFIG","handlingStrategy":"validation","validationCode":"import os\nv = os.environ.get(\"POLARS_IO_SINK_BYTES_BUFFERER_CONFIG\")\nif v is not None:\n    # must be fully consumable with ordered ranges; if unsure of format, unset\n    print(f\"warning: custom bufferer config set: {v!r}\")","typeGuard":"def bufferer_config_suspect(s: str) -> bool:\n    return s.strip() == \"\" or \"..\" not in s","tryCatchPattern":"# Cannot catch the panic; defensively unset questionable values before importing/running polars sink:\nv = os.environ.get(\"POLARS_IO_SINK_BYTES_BUFFERER_CONFIG\")\nif v and (\"..\" not in v):\n    del os.environ[\"POLARS_IO_SINK_BYTES_BUFFERER_CONFIG\"]","preventionTips":["Prefer unset + documented defaults over hand-crafted config strings","Ensure both ranges satisfy start <= end and no trailing tokens","Copy the format exactly from the version's docs/source","Guard long env values against truncation in manifests"],"tags":["environment-variable","panic","configuration","io-sink"],"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"}