{"record":{"id":"d5d797686ddf578b","repo":"pola-rs/polars","slug":"invalid-value-for-polars-inflight-init-byte-budget","errorCode":null,"errorMessage":"invalid value for POLARS_INFLIGHT_INIT_BYTE_BUDGET: {x}","messagePattern":"invalid value for POLARS_INFLIGHT_INIT_BYTE_BUDGET: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-io/src/cloud/concurrency/mod.rs","lineNumber":108,"sourceCode":"            // Must be >=larger than target_chunk_size to avoid potential deadlock.\n            floor_byte_budget: target_chunk_size,\n\n            // Count-based budget.\n            request_budget: get_request_budget(),\n            floor_request_budget: get_floor_request_budget(),\n            control_interval: Duration::from_millis(100),\n            budget_resize_threshold: 0.05,\n        }\n    }\n}\n\n/// Max number of bytes concurrently in flight during the init and start of rampup phase.\nfn get_init_byte_budget(target_chunk_size: u64) -> u64 {\n    let init_byte_budget = std::env::var(\"POLARS_INFLIGHT_INIT_BYTE_BUDGET\")\n        .map(|x| {\n            x.parse::<NonZeroU64>()\n                .unwrap_or_else(|_| {\n                    panic!(\"invalid value for POLARS_INFLIGHT_INIT_BYTE_BUDGET: {x}\")\n                })\n                .get()\n        })\n        .unwrap_or_else(|_| {\n            // This should be lower than the expected BDP so it can ramp-up, but\n            // too low a value delays the transition to stable.\n            // Heuristic: higher bandwidth is expected on larger instances.\n            let n = polars_config::config().max_threads() as u64;\n            n.div_ceil(8).max(4) * target_chunk_size\n        })\n        .max(1);\n\n    if init_byte_budget < target_chunk_size {\n        panic!(\"in-flight byte budget init must be larger than the target_chunk_size\");\n    }\n\n    init_byte_budget\n}","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-io/src/cloud/concurrency/mod.rs#L90-L126","documentation":"Polars parses the POLARS_INFLIGHT_INIT_BYTE_BUDGET environment variable as a NonZeroU64 to size the byte budget kept in flight during the init/ramp-up phase of cloud downloads. If the variable is set but cannot be parsed as a non-zero 64-bit integer, the library panics with this message. It is a fail-fast configuration guard, not a recoverable runtime failure.","triggerScenarios":"Setting POLARS_INFLIGHT_INIT_BYTE_BUDGET to a value that fails NonZeroU64::parse: empty string, non-numeric text ('64MB', 'auto'), zero ('0'), negative numbers ('-5'), or a number exceeding u64 range.","commonSituations":"Copy-pasting a unit-suffixed value like '128M' from documentation; setting the variable to '0' intending 'unlimited'; shell quoting mistakes leaving whitespace or quotes in the value; setting it in a Dockerfile or CI for a different Polars version.","solutions":["Set POLARS_INFLIGHT_INIT_BYTE_BUDGET to a plain positive integer without units, e.g. 134217728 (not 128M).","Unset the variable entirely (env::remove_var / unset in shell) to use the computed default (max_threads/8, min 4, times target chunk size).","Check the value with `echo \"$POLARS_INFLIGHT_INIT_BYTE_BUDGET\"` and `env | grep POLARS` for stray whitespace, quotes, or carriage returns.","If a wrapper script sets it, guard with a numeric check before export."],"exampleFix":"// before\nexport POLARS_INFLIGHT_INIT_BYTE_BUDGET=128M\n// after\nexport POLARS_INFLIGHT_INIT_BYTE_BUDGET=134217728","handlingStrategy":"validation","validationCode":"const v = process.env.POLARS_INFLIGHT_INIT_BYTE_BUDGET;\nif (v !== undefined && (!/^\\d+$/.test(v.trim()) || BigInt(v) === 0n || BigInt(v) > 18446744073709551615n)) {\n  throw new Error(`POLARS_INFLIGHT_INIT_BYTE_BUDGET must be a non-zero u64, got: ${v}`);\n}","typeGuard":"const isValidBudget = (v) => typeof v === 'string' && /^\\d+$/.test(v.trim()) && BigInt(v) > 0n && BigInt(v) <= 18446744073709551615n;","tryCatchPattern":null,"preventionTips":["Never use unit suffixes (K/M/G) in POLARS_* numeric env vars — raw byte counts only.","Never set these variables to 0; omit them for defaults.","Add an entrypoint script check that validates all POLARS_ numeric vars at container start."],"tags":["rust","env-var","configuration","panic","cloud-io"],"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"}