{"record":{"id":"6230b30d4738cb8d","repo":"Pumpkin-MC/Pumpkin","slug":"expected-i32","errorCode":null,"errorMessage":"expected i32","messagePattern":"expected i32","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/pumpkin-protocol/src/serial/deserializer.rs","lineNumber":311,"sourceCode":"\nimpl<'a> PacketReadSlice<'a> for i16 {\n    fn read_slice(buf: &mut &'a [u8]) -> Result<Self, Error> {\n        if buf.len() < 2 {\n            return Err(Error::new(ErrorKind::UnexpectedEof, \"expected i16\"));\n        }\n        let (bytes, rest) = buf.split_at(2);\n        *buf = rest;\n        let arr = bytes\n            .try_into()\n            .map_err(|_| Error::new(ErrorKind::InvalidData, \"invalid i16 slice\"))?;\n        Ok(Self::from_le_bytes(arr))\n    }\n}\n\nimpl<'a> PacketReadSlice<'a> for i32 {\n    fn read_slice(buf: &mut &'a [u8]) -> Result<Self, Error> {\n        if buf.len() < 4 {\n            return Err(Error::new(ErrorKind::UnexpectedEof, \"expected i32\"));\n        }\n        let (bytes, rest) = buf.split_at(4);\n        *buf = rest;\n        let arr = bytes\n            .try_into()\n            .map_err(|_| Error::new(ErrorKind::InvalidData, \"invalid i32 slice\"))?;\n        Ok(Self::from_le_bytes(arr))\n    }\n}\n\nimpl<'a> PacketReadSlice<'a> for i64 {\n    fn read_slice(buf: &mut &'a [u8]) -> Result<Self, Error> {\n        if buf.len() < 8 {\n            return Err(Error::new(ErrorKind::UnexpectedEof, \"expected i64\"));\n        }\n        let (bytes, rest) = buf.split_at(8);\n        *buf = rest;\n        let arr = bytes","sourceCodeStart":293,"sourceCodeEnd":329,"githubUrl":"https://github.com/Pumpkin-MC/Pumpkin/blob/8d4639e25a57c15e47448ec327c780d41bbf2356/crates/pumpkin-protocol/src/serial/deserializer.rs#L293-L329","documentation":"Thrown by `PacketReadSlice for i32` when fewer than 4 bytes remain in the buffer. Decoding a little-endian i32 requires exactly 4 bytes. This UnexpectedEof error signals a truncated payload or field misalignment.","triggerScenarios":"i32::read_slice called when buf.len() < 4 — the remaining bytes cannot supply a full 32-bit integer.","commonSituations":"Truncated packet; misalignment caused by an earlier variable-length field (VarUInt) parsing fewer/more bytes than expected; wrong protocol field order.","solutions":["Verify at least 4 bytes remain before decoding the field","Re-check earlier VarUInt reads for byte-count correctness","Validate payload length against the packet header","Reject the malformed packet and log the offset"],"exampleFix":"// before\nlet pos_x = i32::read_slice(&mut buf)?;\n// after\nif buf.len() < 4 { return Err(PacketError::Truncated); }\nlet pos_x = i32::read_slice(&mut buf)?;","handlingStrategy":"try-catch","validationCode":"if buf.len() < 4 { return Err(PacketError::Truncated); }","typeGuard":null,"tryCatchPattern":"let x = i32::read_slice(&mut buf)\n    .map_err(|_| PacketError::Truncated)?;","preventionTips":["Track remaining byte count as fields are decoded","Validate total payload size before starting deserialization","Fix earlier variable-length field parsing before assuming later fields are corrupt"],"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"}