{"record":{"id":"02be06999d5545fd","repo":"pola-rs/polars","slug":"the-batch-is-not-available","errorCode":null,"errorMessage":"The batch is not available","messagePattern":"The batch is not available","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-arrow/src/io/ipc/read/stream.rs","lineNumber":83,"sourceCode":"/// just doesn't hold any data right now.\npub enum StreamState {\n    /// A live stream without data\n    Waiting,\n    /// Next item in the stream\n    Some(RecordBatchT<Box<dyn Array>>),\n}\n\nimpl StreamState {\n    /// Return the data inside this wrapper.\n    ///\n    /// # Panics\n    ///\n    /// If the `StreamState` was `Waiting`.\n    pub fn unwrap(self) -> RecordBatchT<Box<dyn Array>> {\n        if let StreamState::Some(batch) = self {\n            batch\n        } else {\n            panic!(\"The batch is not available\")\n        }\n    }\n}\n\n/// Reads the next item, yielding `None` if the stream is done,\n/// and a [`StreamState`] otherwise.\nfn read_next<R: Read + Seek>(\n    reader: &mut R,\n    metadata: &StreamMetadata,\n    dictionaries: &mut Dictionaries,\n    message_buffer: &mut Vec<u8>,\n    projection: &Option<ProjectionInfo>,\n    scratch: &mut Vec<u8>,\n    checked: UnsafeBool,\n) -> PolarsResult<Option<StreamState>> {\n    // determine metadata length\n    let mut meta_length: [u8; 4] = [0; 4];\n","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-arrow/src/io/ipc/read/stream.rs#L65-L101","documentation":"StreamState::unwrap() panics when called on the Waiting variant. Waiting means the async/live stream is still open and simply has no batch available yet; calling unwrap there discards the distinction between 'no data yet' and 'data present' and panics.","triggerScenarios":"Thrown at crates/polars-arrow/src/io/ipc/read/stream.rs:83 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Match on StreamState instead of unwrapping; handle Waiting by polling again or awaiting the next item","Only call unwrap after the stream signalled readiness or completion","Convert StreamState to an Option/Result and handle None explicitly"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}