{"record":{"id":"2952dcbfc542dff6","repo":"pola-rs/polars","slug":"invalid-value-for-polars-max-open-sinks-x","errorCode":null,"errorMessage":"invalid value for POLARS_MAX_OPEN_SINKS: {x}","messagePattern":"invalid value for POLARS_MAX_OPEN_SINKS: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-stream/src/nodes/io_sinks/config.rs","lineNumber":49,"sourceCode":"        if let Ok(v) = std::env::var(\"POLARS_INFLIGHT_SINK_MORSEL_LIMIT\").map(|x| {\n            x.parse::<NonZeroUsize>().unwrap_or_else(|_| {\n                panic!(\"invalid value for POLARS_INFLIGHT_SINK_MORSEL_LIMIT: {x}\")\n            })\n        }) {\n            return v;\n        };\n\n        NonZeroUsize::saturating_add(\n            num_pipelines,\n            // Additional buffer to accommodate head-of-line blocking\n            4,\n        )\n    }\n\n    pub fn max_open_sinks(&self) -> NonZeroUsize {\n        if let Ok(v) = std::env::var(\"POLARS_MAX_OPEN_SINKS\").map(|x| {\n            x.parse::<NonZeroUsize>()\n                .unwrap_or_else(|_| panic!(\"invalid value for POLARS_MAX_OPEN_SINKS: {x}\"))\n        }) {\n            return v;\n        }\n\n        if self.target.is_cloud_location() {\n            const { NonZeroUsize::new(512).unwrap() }\n        } else {\n            const { NonZeroUsize::new(128).unwrap() }\n        }\n    }\n\n    pub fn cloud_upload_chunk_size(&self) -> Option<NonZeroUsize> {\n        // Only when `is_cloud_location() == true`. This excludes FORCE_ASYNC'ed local paths,\n        // to avoid unnecessary memory copying.\n        polars_io::configs::env_upload_chunk_size().or((self.target.is_cloud_location()\n            || self.file_write_format_requires_buffering())\n        .then_some(DEFAULT_UPLOAD_CHUNK_SIZE))\n    }","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-stream/src/nodes/io_sinks/config.rs#L31-L67","documentation":"Polars reads POLARS_MAX_OPEN_SINKS to cap how many sink files may be open concurrently in a partitioned sink. An unparsable (or zero) value panics at config resolution time, since a non-zero usize is required.","triggerScenarios":"Setting POLARS_MAX_OPEN_SINKS to a non-positive-integer value ('0', 'ten', '', '2.5') and then running a partitioned sink (sink_parquet with partition_by, which calls max_open_sinks from start_partition_sink_pipeline).","commonSituations":"Tuning concurrent file writes for partitioned output and mistyping the value; container/k8s manifests with malformed env entries; using '0' intending 'unlimited'.","solutions":["Set a positive integer, e.g. export POLARS_MAX_OPEN_SINKS=32.","Unset the variable to fall back to defaults (512 for cloud targets, otherwise the internal default).","Remove any 'unlimited' style values; there is no sentinel — only a positive number or unset."],"exampleFix":"# before\nPOLARS_MAX_OPEN_SINKS=0\n# after\nPOLARS_MAX_OPEN_SINKS=32","handlingStrategy":"validation","validationCode":"import os\nv = os.environ.get(\"POLARS_MAX_OPEN_SINKS\")\nif v is not None:\n    assert v.isdigit() and int(v) > 0, f\"POLARS_MAX_OPEN_SINKS must be a positive integer, got {v!r}\"","typeGuard":"def is_positive_int(s: str) -> bool:\n    return s.isdigit() and int(s) > 0","tryCatchPattern":"if not (os.environ.get(\"POLARS_MAX_OPEN_SINKS\") or \"1\").isdigit() or int(os.environ[\"POLARS_MAX_OPEN_SINKS\"]) < 1:\n    del os.environ[\"POLARS_MAX_OPEN_SINKS\"]  # fall back to defaults","preventionTips":["No 'unlimited' sentinel exists — use a large positive int or unset","Validate env in deployment manifests (k8s lint / entrypoint check)","Sanitize values copied from tuning docs (strip units/whitespace)","Verify sink-partition jobs' env blocks in CI"],"tags":["environment-variable","panic","configuration","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"}