{"record":{"id":"18485198fdaa0a52","repo":"Pumpkin-MC/Pumpkin","slug":"expected-bool-byte","errorCode":null,"errorMessage":"expected bool byte","messagePattern":"expected bool byte","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/pumpkin-protocol/src/serial/deserializer.rs","lineNumber":269,"sourceCode":"    }\n}\n\nimpl<T: PacketRead> PacketRead for Option<T> {\n    fn read<R: Read>(reader: &mut R) -> Result<Self, Error> {\n        bool::read(reader)?.then(|| T::read(reader)).transpose()\n    }\n}\n\nimpl PacketRead for Cow<'_, str> {\n    fn read<R: Read>(reader: &mut R) -> Result<Self, Error> {\n        Ok(Self::Owned(String::read(reader)?))\n    }\n}\n\nimpl<'a> PacketReadSlice<'a> for bool {\n    fn read_slice(buf: &mut &'a [u8]) -> Result<Self, Error> {\n        if buf.is_empty() {\n            return Err(Error::new(ErrorKind::UnexpectedEof, \"expected bool byte\"));\n        }\n        let b = buf[0];\n        *buf = &buf[1..];\n        Ok(b != 0)\n    }\n}\n\nimpl<'a> PacketReadSlice<'a> for u8 {\n    fn read_slice(buf: &mut &'a [u8]) -> Result<Self, Error> {\n        if buf.is_empty() {\n            return Err(Error::new(ErrorKind::UnexpectedEof, \"expected u8\"));\n        }\n        let b = buf[0];\n        *buf = &buf[1..];\n        Ok(b)\n    }\n}\n","sourceCodeStart":251,"sourceCodeEnd":287,"githubUrl":"https://github.com/Pumpkin-MC/Pumpkin/blob/8d4639e25a57c15e47448ec327c780d41bbf2356/crates/pumpkin-protocol/src/serial/deserializer.rs#L251-L287","documentation":"Thrown by `PacketReadSlice for bool` when the buffer is empty, i.e. there is no byte left to interpret as a boolean. It signals premature end of the packet payload during slice-based deserialization. The ErrorKind is UnexpectedEof.","triggerScenarios":"Calling bool::read_slice on an exhausted/short buffer — e.g. the packet body ended earlier than the struct layout expects.","commonSituations":"Truncated packet from a malformed sender; struct field order mismatch with the actual wire layout; packet cut short by network issues before full read.","solutions":["Check the packet's declared length vs. bytes actually received before deserializing","Confirm the field order matches the protocol specification","Validate the payload is complete before calling read_slice","Handle the error and drop the malformed packet"],"exampleFix":"// before\nlet keep_alive: bool = bool::read_slice(&mut buf)?; // may hit empty buf\n// after\nif buf.is_empty() {\n    log::warn!(\"packet too short for bool field\");\n    return Err(PacketError::Truncated);\n}\nlet keep_alive = bool::read_slice(&mut buf)?;","handlingStrategy":"try-catch","validationCode":"if buf.is_empty() { return Err(PacketError::Truncated); }","typeGuard":null,"tryCatchPattern":"match bool::read_slice(&mut buf) {\n    Ok(b) => b,\n    Err(e) if e.kind() == ErrorKind::UnexpectedEof => return Err(PacketError::Truncated),\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Validate the packet's declared length before deserializing fields","Keep struct field order exactly matching the wire layout","Use slice-based readers so EOF surfaces instead of panicking"],"tags":["protocol","serialization","truncated-packet"],"backgroundTag":"unexpected-eof","analyzedSha":"8d4639e25a57c15e47448ec327c780d41bbf2356","analyzedAt":"2026-09-09T15:32:22.916Z","contentChangedAt":"2026-09-09T15:32:22.916Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}