Pumpkin-MC/Pumpkin · error

invalid Bedrock respawn state

Error message

invalid Bedrock respawn state {state}

What it means

Validation guard in RespawnState::read: the client sent a SRespawn (serverbound respawn) packet whose state byte is not one of the known values 0 (SearchingForSpawn), 1 (ReadyToSpawn) or 2 (ClientReadyToSpawn). The offending input is the raw state u8 from the packet — anything outside 0-2 means a protocol mismatch or a non-vanilla client.

Solutions

  1. Drop the invalid respawn packet
  2. Handle only the three defined states and reject others
  3. Log the raw state byte at debug level

Example fix

// before
match u8::read(reader)? {
    0 => Ok(Self::SearchingForSpawn),
    1 => Ok(Self::ReadyToSpawn),
    2 => Ok(Self::ClientReadyToSpawn),
    state => Err(...),
}
// after (if protocol adds state 3)
match u8::read(reader)? {
    0 => Ok(Self::SearchingForSpawn),
    1 => Ok(Self::ReadyToSpawn),
    2 => Ok(Self::ClientReadyToSpawn),
    3 => Ok(Self::NewState),
    state => Err(...),
}
Defensive patterns

Strategy: type-guard

Validate before calling

fn is_valid_respawn_state(b: u8) -> bool { b <= 2 }
// check before decode if you own the byte: if !is_valid_respawn_state(raw) { reject }

Type guard

fn parse_respawn_state(b: u8) -> Option<RespawnState> {
    match b { 0 => Some(RespawnState::SearchingForSpawn), 1 => Some(RespawnState::ReadyToSpawn), 2 => Some(RespawnState::ClientReadyToSpawn), _ => None }
}

Try / catch

match RespawnState::read(reader) {
    Ok(s) => handle_respawn(s),
    Err(e) if e.kind() == std::io::ErrorKind::InvalidData => { log::warn!("bad respawn state"); disconnect(peer); }
    Err(e) => Err(e.into()),
}

Prevention

When it happens

Trigger: Respawn packet whose u8 state field is not 0, 1, or 2 — from corruption, misaligned reads, or a protocol version difference shifting the field.

Common situations: Client/server protocol mismatch after a Bedrock update, network corruption, or crafted packets.

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


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

Appendix: source

Thrown at crates/pumpkin-protocol/src/bedrock/server/respawn.rs:35

    pub state: RespawnState,
    pub player_runtime_id: VarULong,
}

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum RespawnState {
    SearchingForSpawn,
    ReadyToSpawn,
    ClientReadyToSpawn,
}

impl PacketRead for RespawnState {
    fn read<R: Read>(reader: &mut R) -> Result<Self, Error> {
        match u8::read(reader)? {
            0 => Ok(Self::SearchingForSpawn),
            1 => Ok(Self::ReadyToSpawn),
            2 => Ok(Self::ClientReadyToSpawn),
            state => Err(Error::new(
                ErrorKind::InvalidData,
                format!("invalid Bedrock respawn state {state}"),
            )),
        }
    }
}

impl PacketWrite for RespawnState {
    fn write<W: Write>(&self, writer: &mut W) -> Result<(), Error> {
        (*self as u8).write(writer)
    }
}

#[cfg(test)]
mod tests {
    use super::*;
    use crate::serial::PacketRead;

View on GitHub (pinned to 8d4639e25a)