Pumpkin-MC/Pumpkin · error
Bitset too large
Error message
Bitset too large
What it means
Thrown when decoding a VarInt-encoded bitset that exceeds the maximum supported size of the u128 backing storage (more than 18 7-bit groups / 128 bits of data). The reader stops after the fixed loop bound and returns InvalidData rather than silently truncating.
Solutions
- Confirm the client protocol version matches the pumpkin-protocol definitions; update if the field's bitset width changed.
- Validate the bitset's length prefix before decoding; reject oversized inputs at the packet boundary.
- Check for packet corruption — a missing terminator byte (0x80 flag never cleared) will also hit this limit.
- If a wider bitset is genuinely required, widen the internal storage (e.g. to a larger integer or array) in the codec.
Defensive patterns
Strategy: validation
Validate before calling
// Reject bitsets wider than u128 before decoding
if declared_len > 18 { return Err(Error::new(ErrorKind::InvalidData, "bitset too large")); } Try / catch
match Bitset::read(reader) {
Ok(b) => Ok(b),
Err(e) if e.kind() == ErrorKind::InvalidData => {
log::warn!("oversized bitset; likely corrupt stream");
Err(DecodeError::Desync)
}
Err(e) => Err(e.into()),
} Prevention
- Enforce the field's documented bitset width at the packet boundary.
- Always consume exactly the encoded length; never guess.
- Disconnect on first decode failure to avoid cascading desync.
When it happens
Trigger: Reading a bitset whose VarInt payload has more continuation groups than the read loop allows (a bitset larger than 128 bits, or a corrupted/missing terminator byte so the loop runs to exhaustion).
Common situations: Server/client disagreement on bitset width for a field (e.g. abilities or recipe flags); malicious or corrupt packets on the wire; a protocol version that widened the bitset.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- too many player input flags
- VarLong is too big (overflow)
- {0}
- extra_data_len exceeds 1MB limit
- extra_data length exceeds limit
AI-assisted analysis of Pumpkin-MC/Pumpkin@8d4639e25a (2026-09-09).
Data as JSON: /api/errors/6ee542eab5119c2d.
Report an issue: GitHub.
Appendix: source
Thrown at crates/pumpkin-protocol/src/codec/bitset.rs:46
impl<const N: usize> Default for Bitset<N> {
fn default() -> Self {
assert!(N <= 80,);
Self { bits: 0 }
}
}
impl<const N: usize> PacketRead for Bitset<N> {
fn read<R: Read>(reader: &mut R) -> Result<Self, Error> {
let mut bitset = Self::default();
for i in 0..N.div_ceil(7) {
let byte = u8::read(reader)?;
bitset.bits |= (u128::from(byte) & 0x7F) << (i * 7);
if byte & 0x80 == 0 {
return Ok(bitset);
}
}
Err(Error::new(ErrorKind::InvalidData, "Bitset too large"))
}
}
View on GitHub (pinned to 8d4639e25a)