Pumpkin-MC/Pumpkin · warning · PacketError
Unknown packet type
Error message
Unknown packet type: {0} What it means
RconError::UnknownPacketType is thrown when an RCON packet's type field is an i32 that this implementation does not recognize. The Source RCON protocol defines only a few packet types (3=login, 2=command, 0=response/auth); any other value cannot be dispatched. This guards the server (or client) against protocol misuse and probing.
Solutions
- Identify the client producing the packet and fix its packet-type value to a defined one (SERVERDATA_AUTH=3, SERVERDATA_EXECCOMMAND=2, SERVERDATA_RESPONSE_VALUE=0).
- Log the offending i32 and close or ignore the connection; treat it as protocol abuse.
- Update the library if a new official packet type must be supported.
- Reject the packet early after reading the type field instead of decoding the body.
Example fix
// before: blindly sending a custom type
let packet = Packet { id, pkt_type: 99, body };
// after: use a defined type
use PacketType::Command;
let packet = Packet { id, pkt_type: Command, body }; Defensive patterns
Strategy: validation
Validate before calling
// validate the type field before dispatch
const VALID: [i32; 3] = [0, 2, 3];
if !VALID.contains(&pkt_type) {
drop_connection("unknown RCON packet type");
} Type guard
fn known_packet_type(t: i32) -> Option<PacketType> {
match t { 0 => Some(PacketType::Response), 2 => Some(PacketType::Command), 3 => Some(PacketType::Auth), _ => None }
} Try / catch
match decode_result {
Err(RconError::UnknownPacketType(t)) => {
warn!("rcon peer sent unknown type {t}; closing");
connection.shutdown().await;
}
other => /* ... */,
} Prevention
- Use the library's enum types instead of raw i32 when building packets.
- Restrict RCON to trusted networks and require strong authentication.
- Log unknown type values to spot misbehaving clients or scanners early.
When it happens
Trigger: Decoding an inbound RCON packet whose type field is outside the known set {0, 2, 3}; happens in Packet::decode when it calls the type-to-enum conversion with an unrecognized i32.
Common situations: A custom or buggy RCON client sending an invented packet type; a port scan or exploitation attempt sending random i32s; protocol version drift where a sender uses an extended type the receiver does not know.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Invalid packet string body
- Failed to parse JSON into Game Profile
- Invalid URL
- Invalid slot
- Player ' ' tried to interact with a closed container
AI-assisted analysis of Pumpkin-MC/Pumpkin@8d4639e25a (2026-09-09).
Data as JSON: /api/errors/3264cff2a7b01e88.
Report an issue: GitHub.
Appendix: source
Thrown at crates/pumpkin-protocol/src/rcon.rs:60
let bytes = body.as_bytes();
buf.put_slice(bytes);
buf.put_u8(0);
buf.put_u8(0);
buf
}
}
#[derive(Error, Debug)]
pub enum PacketError {
#[error("Invalid length")]
InvalidLength,
#[error("Failed to send packet: {0}")]
FailedSend(std::io::Error),
#[error("Missing packet null terminator")]
MissingNullTerminator,
#[error("Invalid packet string body: {0}")]
InvalidBody(std::str::Utf8Error),
#[error("Unknown packet type: {0}")]
UnknownPacketType(i32),
}
#[derive(Debug, PartialEq, Eq)]
/// Serverbound packet
pub struct Packet {
id: i32,
ptype: ServerboundPacket,
body: Box<str>,
}
impl Packet {
pub fn deserialize(incoming: &mut Vec<u8>) -> Result<Option<Self>, PacketError> {
// We need at least 4 bytes to read the packet length header
if incoming.len() < 4 {
return Ok(None);
}
View on GitHub (pinned to 8d4639e25a)