{"record":{"id":"66e188760cef9515","repo":"Pumpkin-MC/Pumpkin","slug":"unknown-text-type","errorCode":null,"errorMessage":"Unknown Text Type","messagePattern":"Unknown Text Type","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/pumpkin-protocol/src/bedrock/server/text.rs","lineNumber":303,"sourceCode":"    }\n}\n\nimpl PacketRead for TextPacketType {\n    fn read<R: Read>(reader: &mut R) -> Result<Self, Error> {\n        match u8::read(reader)? {\n            0 => Ok(Self::Raw),\n            1 => Ok(Self::Chat),\n            2 => Ok(Self::Translation),\n            3 => Ok(Self::Popup),\n            4 => Ok(Self::JukeboxPopup),\n            5 => Ok(Self::Tip),\n            6 => Ok(Self::System),\n            7 => Ok(Self::Whisper),\n            8 => Ok(Self::Announcement),\n            9 => Ok(Self::JsonWhisper),\n            10 => Ok(Self::Json),\n            11 => Ok(Self::JsonAnnouncement),\n            _ => Err(Error::new(ErrorKind::InvalidData, \"Unknown Text Type\")),\n        }\n    }\n}\n\nimpl<'a> PacketReadSlice<'a> for TextPacketType {\n    fn read_slice(buf: &mut &'a [u8]) -> Result<Self, Error> {\n        match u8::read_slice(buf)? {\n            0 => Ok(Self::Raw),\n            1 => Ok(Self::Chat),\n            2 => Ok(Self::Translation),\n            3 => Ok(Self::Popup),\n            4 => Ok(Self::JukeboxPopup),\n            5 => Ok(Self::Tip),\n            6 => Ok(Self::System),\n            7 => Ok(Self::Whisper),\n            8 => Ok(Self::Announcement),\n            9 => Ok(Self::JsonWhisper),\n            10 => Ok(Self::Json),","sourceCodeStart":285,"sourceCodeEnd":321,"githubUrl":"https://github.com/Pumpkin-MC/Pumpkin/blob/8d4639e25a57c15e47448ec327c780d41bbf2356/crates/pumpkin-protocol/src/bedrock/server/text.rs#L285-L321","documentation":"Thrown when decoding a Bedrock Text packet whose type byte does not map to any known TextPacketType (valid values are 0–11: raw, chat, tip, etc.). Unknown type means the packet layout cannot be interpreted, so decoding fails with InvalidData.","triggerScenarios":"Text packet where the type byte read from the buffer is outside 0..=11, e.g. due to misaligned parsing, corruption, or a newer client protocol adding a type this server doesn't know.","commonSituations":"Bedrock version mismatch (new text types in newer clients), chat plugins/proxies injecting malformed text packets, corrupted packets.","solutions":["Update the pumpkin-protocol crate to support the client's Bedrock protocol version","Check for proxies or plugins rewriting Text packets","Capture raw bytes to identify the unknown type value","Disconnect the client if packets are deliberately malformed"],"exampleFix":"// before\nmatch t {\n    ... 11 => Ok(Self::JsonAnnouncement),\n    _ => Err(Error::new(ErrorKind::InvalidData, \"Unknown Text Type\")),\n}\n// after (support a new type 12)\nmatch t {\n    ... 11 => Ok(Self::JsonAnnouncement),\n    12 => Ok(Self::NewTextType),\n    _ => Err(Error::new(ErrorKind::InvalidData, \"Unknown Text Type\")),\n}","handlingStrategy":"try-catch","validationCode":"fn is_known_text_type(b: u8) -> bool { b <= 11 } // guard raw bytes before decode if available","typeGuard":"fn parse_text_type(b: u8) -> Option<TextPacketType> { TextPacketType::read(&mut &b.to_vec()[..]).ok() }","tryCatchPattern":"match TextPacketType::read(buf) {\n    Ok(t) => handle_text(t),\n    Err(e) if e.kind() == std::io::ErrorKind::InvalidData => { log::warn!(\"unknown text type from peer\"); disconnect(peer); }\n    Err(e) => Err(e.into()),\n}","preventionTips":["Keep the protocol crate updated when Bedrock adds new text types","Never inject text packets from plugins without encoding the type via the protocol crate","Add round-trip tests covering every TextPacketType variant","Log the offending type byte to spot new protocol values quickly"],"tags":["bedrock","protocol","packet-decoding","enum"],"backgroundTag":"invalid-enum-value","analyzedSha":"8d4639e25a57c15e47448ec327c780d41bbf2356","analyzedAt":"2026-09-09T15:32:22.916Z","contentChangedAt":"2026-09-09T15:32:22.916Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}