Pumpkin-MC/Pumpkin · error · PacketDecodeError

packet length is out of bounds

Error message

packet length is out of bounds

What it means

PacketDecodeError guard during framed packet reading: the declared packet length does not fit the bounds allowed by the protocol framing (negative, larger than the configured maximum, or smaller than a valid header). The offending input is the packet length field read from the wire — a corrupted frame or a hostile/misbehaving connection.

Solutions

  1. Close the connection as the stream is unusable
  2. Range-check the length prefix before reading the body
  3. Log the bad length at debug level
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/pumpkin-protocol/src/lib.rs:305 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Pumpkin-MC/Pumpkin@8d4639e25a (2026-09-09). Data as JSON: /api/errors/748a92acc9f6729e. Report an issue: GitHub.

Appendix: source

Thrown at crates/pumpkin-protocol/src/lib.rs:305

/// Errors that can occur during packet encoding.
#[derive(Error, Debug)]
pub enum PacketEncodeError {
    #[error("Packet exceeds maximum length: {0}")]
    TooLong(usize),
    #[error("Compression failed {0}")]
    CompressionFailed(String),
    #[error("Writing packet failed: {0}")]
    Message(String),
}

#[derive(Error, Debug)]
pub enum PacketDecodeError {
    #[error("failed to decode packet ID")]
    DecodeID,
    #[error("packet exceeds maximum length")]
    TooLong,
    #[error("packet length is out of bounds")]
    OutOfBounds,
    #[error("malformed packet length VarInt: {0}")]
    MalformedLength(String),
    #[error("failed to decompress packet: {0}")]
    FailedDecompression(String), // Updated to include error details
    #[error("packet is uncompressed but greater than the threshold")]
    NotCompressed,
    #[error("the connection has closed")]
    ConnectionClosed,
    #[error("{0}")]
    Message(String),
}

impl From<ReadingError> for PacketDecodeError {
    fn from(value: ReadingError) -> Self {
        Self::FailedDecompression(value.to_string())
    }
}

View on GitHub (pinned to 8d4639e25a)