{"record":{"id":"311c941aca908cce","repo":"pola-rs/polars","slug":"invalid-value-for-polars-record-batch-prefetch-kby","errorCode":null,"errorMessage":"invalid value for POLARS_RECORD_BATCH_PREFETCH_KBYTES_BUDGET: {x}","messagePattern":"invalid value for POLARS_RECORD_BATCH_PREFETCH_KBYTES_BUDGET: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-stream/src/nodes/io_sources/ipc/builder.rs","lineNumber":75,"sourceCode":"                        panic!(\"invalid value for POLARS_RECORD_BATCH_PREFETCH_SIZE: {x}\")\n                    })\n                    .get()\n            })\n            .unwrap_or(\n                // Similar to Parquet.\n                execution_state\n                    .num_pipelines\n                    .saturating_mul(2)\n                    .max(get_request_budget() as usize)\n                    .clamp(16, 2048),\n            )\n            .max(1);\n\n        let prefetch_kbytes_limit = std::env::var(\"POLARS_RECORD_BATCH_PREFETCH_KBYTES_BUDGET\")\n            .map(|x| {\n                x.parse::<NonZeroUsize>()\n                    .unwrap_or_else(|_| {\n                        panic!(\"invalid value for POLARS_RECORD_BATCH_PREFETCH_KBYTES_BUDGET: {x}\")\n                    })\n                    .get()\n            })\n            .unwrap_or({\n                // Similar to Parquet.\n                let target_chunk_size_kb = FetchConfig::random_access().chunk_size.div_ceil(1024);\n                4 * execution_state.num_pipelines * target_chunk_size_kb\n            })\n            // Avoid deadlock.\n            .max(polars_io::cloud::concurrency_config::get_download_chunk_size().div_ceil(1024));\n\n        if config::verbose() {\n            eprintln!(\n                \"[IpcReaderBuilder]: prefetch_limit: {}, prefetch_kbytes_limit: {}\",\n                prefetch_limit, prefetch_kbytes_limit\n            );\n        }\n","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-stream/src/nodes/io_sources/ipc/builder.rs#L57-L93","documentation":"Polars panics when POLARS_RECORD_BATCH_PREFETCH_KBYTES_BUDGET is set but cannot be parsed as a non-zero usize. The IPC source builder reads it in set_execution_state as a byte-budget (in KiB) for prefetched batches; unset falls back to a budget computed from FetchConfig's target chunk size.","triggerScenarios":"Starting a streaming IPC scan with the variable set to a non-numeric, zero, negative, or out-of-range string (e.g. '10MB', '', '0').","commonSituations":"Operators copy a memory budget like '262144KB' or '256MB' from tuning notes; the 'KB'/'MB' suffix and empty values are the usual culprits.","solutions":["Set the variable to a bare positive integer number of KiB, e.g. 262144.","Unset the variable to use the default budget derived from FetchConfig::random_access().chunk_size.","Strip any unit suffixes or whitespace from the value before export."],"exampleFix":"// before\nPOLARS_RECORD_BATCH_PREFETCH_KBYTES_BUDGET=256MB\n// after\nPOLARS_RECORD_BATCH_PREFETCH_KBYTES_BUDGET=262144","handlingStrategy":"validation","validationCode":"const v = process.env.POLARS_RECORD_BATCH_PREFETCH_KBYTES_BUDGET;\nif (v !== undefined && (!/^\\d+$/.test(v.trim()) || parseInt(v, 10) === 0)) {\n  throw new Error(`POLARS_RECORD_BATCH_PREFETCH_KBYTES_BUDGET must be a positive integer (KiB), got: '${v}'`);\n}","typeGuard":"function isValidKbytesBudget(v) { return v === undefined || (/^\\d+$/.test(v.trim()) && Number(v.trim()) > 0); }","tryCatchPattern":"try {\n  runIpcScan();\n} catch (e) {\n  if (String(e).includes('PREFETCH_KBYTES_BUDGET')) {\n    delete process.env.POLARS_RECORD_BATCH_PREFETCH_KBYTES_BUDGET;\n    runIpcScan();\n  } else throw e;\n}","preventionTips":["Remember the unit is KiB — never append KB/MB suffixes.","Compute MB -> KiB in your deployment tooling, not by hand in env files.","Centralize Polars tuning env vars in one validated config module."],"tags":["rust","env-var","ipc","config"],"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"}