{"record":{"id":"37123066bd0b164b","repo":"pola-rs/polars","slug":"invalid-value-for-polars-ideal-sink-morsel-size-bytes-x","errorCode":null,"errorMessage":"invalid value for POLARS_IDEAL_SINK_MORSEL_SIZE_BYTES: {x}","messagePattern":"invalid value for POLARS_IDEAL_SINK_MORSEL_SIZE_BYTES: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-stream/src/nodes/io_sinks/writers/interface.rs","lineNumber":79,"sourceCode":"\n        Poll::Ready(file.map(|file| (file, self.sync_on_close)))\n    }\n}\n\n/// Load ideal morsel size configuration from environment variables.\npub(super) fn ideal_sink_morsel_size_env() -> (Option<NonZeroIdxSize>, Option<NonZeroU64>) {\n    let num_rows = std::env::var(\"POLARS_IDEAL_SINK_MORSEL_SIZE_ROWS\")\n        .map(|x| {\n            x.parse::<NonZeroIdxSize>().ok().unwrap_or_else(|| {\n                panic!(\"invalid value for POLARS_IDEAL_SINK_MORSEL_SIZE_ROWS: {x}\")\n            })\n        })\n        .ok();\n\n    let num_bytes = std::env::var(\"POLARS_IDEAL_SINK_MORSEL_SIZE_BYTES\")\n        .map(|x| {\n            x.parse::<NonZeroU64>().ok().unwrap_or_else(|| {\n                panic!(\"invalid value for POLARS_IDEAL_SINK_MORSEL_SIZE_BYTES: {x}\")\n            })\n        })\n        .ok();\n\n    (\n        num_rows,\n        num_bytes.or(num_rows.is_some().then_some(NonZeroU64::MAX)),\n    )\n}\n","sourceCodeStart":61,"sourceCodeEnd":89,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-stream/src/nodes/io_sinks/writers/interface.rs#L61-L89","documentation":"POLARS_IDEAL_SINK_MORSEL_SIZE_BYTES optionally overrides the ideal byte size per sink morsel. It must parse as a non-zero u64; any other value (zero, non-numeric, empty) makes Polars panic while loading sink writer configuration.","triggerScenarios":"Setting POLARS_IDEAL_SINK_MORSEL_SIZE_BYTES to '0', '4MB' (raw u64 expected, not a size-suffixed string), or any unparsable text, then running a streaming sink; read in ideal_sink_morsel_size_env alongside the ROWS variant.","commonSituations":"Adding byte-size suffixes ('8m', '1GB') where a plain integer is required; conflicting/env collisions between ROWS and BYTES tuning vars.","solutions":["Set a plain positive integer byte count, e.g. export POLARS_IDEAL_SINK_MORSEL_SIZE_BYTES=8388608.","Unset the variable and rely on default sizing.","Do not use unit suffixes here unless your Polars version documents them; check docs for your version."],"exampleFix":"# before\nexport POLARS_IDEAL_SINK_MORSEL_SIZE_BYTES=8MB\n# after\nexport POLARS_IDEAL_SINK_MORSEL_SIZE_BYTES=8388608","handlingStrategy":"validation","validationCode":"import os\nv = os.environ.get(\"POLARS_IDEAL_SINK_MORSEL_SIZE_BYTES\")\nif v is not None:\n    assert v.isdigit() and int(v) > 0, f\"must be a plain positive integer byte count, got {v!r}\"","typeGuard":"def is_plain_byte_count(s: str) -> bool:\n    return s.isdigit() and int(s) > 0 and not any(c.isalpha() for c in s)","tryCatchPattern":"v = os.environ.get(\"POLARS_IDEAL_SINK_MORSEL_SIZE_BYTES\", \"\")\nif v and not v.isdigit():\n    os.environ.pop(\"POLARS_IDEAL_SINK_MORSEL_SIZE_BYTES\", None)","preventionTips":["Convert '8MB' style values to plain integers yourself (8 * 1024 * 1024)","No suffix parsing: set 8388608, not 8MB","Check both ROWS and BYTES vars together for consistency","Validate at process start before any sink runs"],"tags":["environment-variable","panic","configuration","morsel"],"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"}