{"record":{"id":"fb2d022478c629dc","repo":"pola-rs/polars","slug":"init-must-be-called-first","errorCode":null,"errorMessage":"init must be called first","messagePattern":"init must be called first","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-arrow/src/io/ipc/read/flight.rs","lineNumber":227,"sourceCode":"\n        let footer = Box::new(footer);\n\n        #[allow(clippy::unnecessary_cast)]\n        let ptr = Box::leak(footer) as *const _ as *const FooterRef<'static>;\n\n        self.footer = Some(ptr);\n        let footer = &unsafe { **self.footer.as_ref().unwrap() };\n\n        self.data_blocks = Some(Box::new(iter_recordbatch_blocks_from_footer(*footer)?)\n            as Box<dyn SendableIterator<Item = _>>);\n        self.dict_blocks = iter_dictionary_blocks_from_footer(*footer)?\n            .map(|i| Box::new(i) as Box<dyn SendableIterator<Item = _>>);\n\n        Ok(())\n    }\n\n    pub fn get_schema(self: &Pin<Box<Self>>) -> PolarsResult<EncodedData> {\n        let footer = &unsafe { **self.footer.as_ref().expect(\"init must be called first\") };\n\n        let schema_ref = deserialize_schema_ref_from_footer(*footer)?;\n        let schema = schema_to_raw_message(schema_ref);\n\n        Ok(schema)\n    }\n\n    pub async fn next_dict(\n        self: &mut Pin<Box<Self>>,\n        encoded_data: &mut EncodedData,\n    ) -> PolarsResult<Option<()>> {\n        assert!(self.data_blocks.is_some(), \"init must be called first\");\n        encoded_data.ipc_message.clear();\n        encoded_data.arrow_data.clear();\n\n        if let Some(iter) = &mut self.dict_blocks {\n            let Some(value) = iter.next() else {\n                return Ok(None);","sourceCodeStart":209,"sourceCodeEnd":245,"githubUrl":"https://github.com/pola-rs/polars/blob/9b5d73fd00236295624374b075d16b1fe6ec6df9/crates/polars-arrow/src/io/ipc/read/flight.rs#L209-L245","documentation":"expect/unwrap-style failure in the IPC flight-data decode path: internal state (e.g. the parsed footer) was consumed before being initialized by a preceding init() call. It indicates a misuse of the reader API ordering rather than bad input data.","triggerScenarios":"This panic/expect fires when execution reaches an unguarded state described by: \"init must be called first\". Typical triggers: unsupported dtype or feature-gated code path reached at runtime, invalid user input or environment variable value, calling API methods in the wrong order or on mismatched types, or data (lengths, offsets, ranges) violating the function's preconditions.","commonSituations":"Encountered when input data or configuration does not meet the preconditions of the throwing code path (\"init must be called first\"). Common cases: missing Cargo feature flags, mismatched dtypes/lengths between arrays or series, out-of-range temporal values, malformed environment variables, or operations on unsupported/complex nested types.","solutions":["Call the stream/reader initialization method (e.g. `init`) before polling for flight data.","Ensure the IPC stream metadata/schema message has been read before requesting record batches."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9b5d73fd00236295624374b075d16b1fe6ec6df9","analyzedAt":"2026-08-19T12:15:06.350Z","contentChangedAt":"2026-08-19T12:15:06.350Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}