{"record":{"id":"17e3321dbaf6f006","repo":"Pumpkin-MC/Pumpkin","slug":"invalid-i16-slice","errorCode":null,"errorMessage":"invalid i16 slice","messagePattern":"invalid i16 slice","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/pumpkin-protocol/src/serial/deserializer.rs","lineNumber":303,"sourceCode":"    }\n}\n\nimpl<'a> PacketReadSlice<'a> for i8 {\n    fn read_slice(buf: &mut &'a [u8]) -> Result<Self, Error> {\n        u8::read_slice(buf).map(|b| b as Self)\n    }\n}\n\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","sourceCodeStart":285,"sourceCodeEnd":321,"githubUrl":"https://github.com/Pumpkin-MC/Pumpkin/blob/8d4639e25a57c15e47448ec327c780d41bbf2356/crates/pumpkin-protocol/src/serial/deserializer.rs#L285-L321","documentation":"A defensive error inside `PacketReadSlice for i16`: after a length check passed and split_at(2) succeeded, try_into to [u8;2] still failed. This is theoretically unreachable given the length check and indicates an internal invariant violation rather than ordinary bad input.","triggerScenarios":"Only possible if the `try_into::<[u8; 2]>` conversion fails despite bytes.len() == 2 — an invariant that should never hold in practice.","commonSituations":"Practically never hit in production; if it appears it indicates a corrupted build or a modified deserializer where the length guard was removed.","solutions":["Verify the library build is unmodified (checksum/rebuild)","File a bug with the byte dump and stack trace if reproducible","Re-run the build; check for conflicting patched versions of pumpkin-protocol"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"let v = i16::read_slice(&mut buf).unwrap_or_else(|e| {\n    debug_assert!(false, \"invariant violated: {e}\");\n    0 // or propagate as internal error\n});","preventionTips":["Never patch out the length guard before try_into","Rebuild from a clean checkout if this unreachable error appears","Report reproducible occurrences upstream as a bug"],"tags":["protocol","internal-invariant","serialization"],"backgroundTag":"internal-invariant-violation","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"}