Pumpkin-MC/Pumpkin · error
invalid i16 slice
Error message
invalid i16 slice
What it means
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.
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
Defensive patterns
Strategy: fallback
Try / catch
let v = i16::read_slice(&mut buf).unwrap_or_else(|e| {
debug_assert!(false, "invariant violated: {e}");
0 // or propagate as internal error
}); Prevention
- 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
When it happens
Trigger: Only possible if the `try_into::<[u8; 2]>` conversion fails despite bytes.len() == 2 — an invariant that should never hold in practice.
Common situations: Practically never hit in production; if it appears it indicates a corrupted build or a modified deserializer where the length guard was removed.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
AI-assisted analysis of Pumpkin-MC/Pumpkin@8d4639e25a (2026-09-09).
Data as JSON: /api/errors/17e3321dbaf6f006.
Report an issue: GitHub.
Appendix: source
Thrown at crates/pumpkin-protocol/src/serial/deserializer.rs:303
}
}
impl<'a> PacketReadSlice<'a> for i8 {
fn read_slice(buf: &mut &'a [u8]) -> Result<Self, Error> {
u8::read_slice(buf).map(|b| b as Self)
}
}
impl<'a> PacketReadSlice<'a> for i16 {
fn read_slice(buf: &mut &'a [u8]) -> Result<Self, Error> {
if buf.len() < 2 {
return Err(Error::new(ErrorKind::UnexpectedEof, "expected i16"));
}
let (bytes, rest) = buf.split_at(2);
*buf = rest;
let arr = bytes
.try_into()
.map_err(|_| Error::new(ErrorKind::InvalidData, "invalid i16 slice"))?;
Ok(Self::from_le_bytes(arr))
}
}
impl<'a> PacketReadSlice<'a> for i32 {
fn read_slice(buf: &mut &'a [u8]) -> Result<Self, Error> {
if buf.len() < 4 {
return Err(Error::new(ErrorKind::UnexpectedEof, "expected i32"));
}
let (bytes, rest) = buf.split_at(4);
*buf = rest;
let arr = bytes
.try_into()
.map_err(|_| Error::new(ErrorKind::InvalidData, "invalid i32 slice"))?;
Ok(Self::from_le_bytes(arr))
}
}
View on GitHub (pinned to 8d4639e25a)