{"record":{"id":"b3a1d264ca3ed8c7","repo":"pola-rs/polars","slug":"invalid-value-for-polars-row-group-prefetch-kbytes","errorCode":null,"errorMessage":"invalid value for POLARS_ROW_GROUP_PREFETCH_KBYTES_BUDGET: {x}","messagePattern":"invalid value for POLARS_ROW_GROUP_PREFETCH_KBYTES_BUDGET: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-stream/src/nodes/io_sources/parquet/builder.rs","lineNumber":102,"sourceCode":"                    .max(get_request_budget() as usize)\n                    .clamp(16, 2048),\n            )\n            .max(1);\n\n        // Bound the max memory in use for the pipeline.\n        // This should be large enough to be non-blocking, but small enough to avoid\n        // excessive memory use from a run-away prefetch pipeline.\n        // \"Correct\" formula: (a) max effective in-flight bdp-based bytes budget + (b) decode pipeline.\n        // Since we do not know (a) at startup, we use  '3 * (b) + buffer' as a proxy for (a), where the\n        // multiplier reflects the max gain factor for in-flight control.\n        // TODO: Dynamically adapt the max memory to the observed BDP.\n        // NOTE: This does not account for the decompression multiplier, so actual memory\n        // usage can be substantially larger.\n        let prefetch_kbytes_limit = std::env::var(\"POLARS_ROW_GROUP_PREFETCH_KBYTES_BUDGET\")\n            .map(|x| {\n                x.parse::<NonZeroUsize>()\n                    .unwrap_or_else(|_| {\n                        panic!(\"invalid value for POLARS_ROW_GROUP_PREFETCH_KBYTES_BUDGET: {x}\")\n                    })\n                    .get()\n            })\n            .unwrap_or({\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                \"[ParquetReaderBuilder]: prefetch_limit: {}, prefetch_kbytes_limit: {}\",\n                prefetch_limit, prefetch_kbytes_limit\n            );\n        }\n\n        self.pipeline_budget","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-stream/src/nodes/io_sources/parquet/builder.rs#L84-L120","documentation":"Polars panics when POLARS_ROW_GROUP_PREFETCH_KBYTES_BUDGET is set but cannot be parsed as a non-zero usize. This variable caps the total kilobytes of Parquet row-group data prefetched concurrently. The default derives from num_pipelines and the FetchConfig chunk size; an unparseable or zero user value triggers this panic in set_execution_state.","triggerScenarios":"Setting POLARS_ROW_GROUP_PREFETCH_KBYTES_BUDGET to a non-numeric string ('512MB'), zero, a negative number, or a value exceeding usize::MAX before a streaming Parquet scan.","commonSituations":"Users express the budget with unit suffixes ('64k', '1G'), or set 0 expecting 'no limit'; CI config templating injects empty strings or 'None'.","solutions":["Unset POLARS_ROW_GROUP_PREFETCH_KBYTES_BUDGET to use the computed default","Set it to a plain positive decimal integer of kilobytes, e.g. export POLARS_ROW_GROUP_PREFETCH_KBYTES_BUDGET=65536","Ensure no units, spaces, or surrounding quotes are included in the value"],"exampleFix":"// before\nPOLARS_ROW_GROUP_PREFETCH_KBYTES_BUDGET=\"\"\n// after\nPOLARS_ROW_GROUP_PREFETCH_KBYTES_BUDGET=65536","handlingStrategy":"validation","validationCode":"// Rust: validate before running the scan\nif let Ok(v) = std::env::var(\"POLARS_ROW_GROUP_PREFETCH_KBYTES_BUDGET\") {\n    assert!(v.parse::<NonZeroUsize>().is_ok(), \"POLARS_ROW_GROUP_PREFETCH_KBYTES_BUDGET must be a positive integer (kilobytes), got: {v}\");\n}","typeGuard":"fn valid_kbytes_budget(v: &str) -> bool { v.parse::<NonZeroUsize>().is_ok() }","tryCatchPattern":null,"preventionTips":["Express the budget in kilobytes as a plain integer (65536, not '64MB')","Ensure templating systems don't emit empty or null strings for this var","Leave unset to use the pipeline-derived default"],"tags":["rust","environment-variable","configuration","parquet"],"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"}