{"record":{"id":"1c0b6c4447debd33","repo":"Pumpkin-MC/Pumpkin","slug":"incomplete-0","errorCode":null,"errorMessage":"incomplete: {0}","messagePattern":"incomplete: (.+?)","errorType":"exception","errorClass":"ReadingError","httpStatus":null,"severity":"error","filePath":"crates/pumpkin-protocol/src/ser/mod.rs","lineNumber":23,"sourceCode":"use crate::{\n    FixedBitSet,\n    codec::{\n        bit_set::BitSet, var_int::VarInt, var_long::VarLong, var_uint::VarUInt, var_ulong::VarULong,\n    },\n};\n\nuse pumpkin_nbt::{\n    compound::NbtCompound, deserializer::NbtReadHelper, serializer::NbtWriteHelperJava, tag::NbtTag,\n};\nuse pumpkin_util::math::position::BlockPos;\nuse pumpkin_util::{text::TextComponent, version::JavaMinecraftVersion};\nuse thiserror::Error;\n\n#[derive(Debug, Error)]\npub enum ReadingError {\n    #[error(\"EOF, Tried to read {0} but No bytes left to consume\")]\n    CleanEOF(String),\n    #[error(\"incomplete: {0}\")]\n    Incomplete(String),\n    #[error(\"too large: {0}\")]\n    TooLarge(String),\n    #[error(\"{0}\")]\n    Message(String),\n}\n\nimpl serde::de::Error for ReadingError {\n    fn custom<T: std::fmt::Display>(msg: T) -> Self {\n        Self::Message(msg.to_string())\n    }\n}\n\n#[derive(Debug, Error)]\npub enum WritingError {\n    #[error(\"IO error: {0}\")]\n    IoError(#[from] std::io::Error),\n    #[error(\"Serde failure: {0}\")]","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/Pumpkin-MC/Pumpkin/blob/8d4639e25a57c15e47448ec327c780d41bbf2356/crates/pumpkin-protocol/src/ser/mod.rs#L5-L41","documentation":"ReadingError::Incomplete signals that a read started successfully but fewer bytes than required were available before the stream ended — the packet is truncated. Unlike CleanEOF (zero bytes available), some bytes arrived, so the peer sent a partially-formed packet or the stream closed mid-packet.","triggerScenarios":"Reading a field whose declared length exceeds the remaining bytes on the wire, e.g. the packet's length prefix says N bytes but the connection closes after M < N bytes; deserializing a truncated frame from the TCP stream.","commonSituations":"Network interruption mid-packet (client dropped, proxy cut the connection); a buggy sender computing the length field wrong so the receiver waits for bytes never sent; MTU/proxy issues that chop streams; reading from a socket after the peer aborted.","solutions":["Verify the sender computes the packet length field as the exact remaining byte count (id + type + body + null terminators).","Discard the partial packet and close/reconnect; a truncated frame cannot be recovered from a stream.","Add network diagnostics between peers (proxies, load balancers) if truncation recurs.","Log the expected vs actual byte counts to identify which field of which packet truncates."],"exampleFix":"// before: sender writes body but a wrong length prefix\nlet len = body.len() as i32; // forgot id+type+terminators\nstream.write_all(&len.to_be_bytes()).await?;\n\n// after: compute full packet length\nlet len = (4 + 4 + body.len() + 2) as i32;\nstream.write_all(&len.to_be_bytes()).await?;","handlingStrategy":"try-catch","validationCode":"// before decoding a framed packet, ensure the full frame is buffered\nif buffer.len() < frame_len {\n    return Ok(None); // wait for more bytes instead of decoding a partial frame\n}","typeGuard":null,"tryCatchPattern":"match decode(&mut buf).await {\n    Err(ReadingError::Incomplete(exp)) => {\n        warn!(\"truncated packet, expected {exp}; resetting connection\");\n        connection.close().await;\n    }\n    other => /* ... */,\n}","preventionTips":["Compute packet length fields to include id + type + body + trailing nulls exactly.","Buffer the complete frame before deserializing rather than streaming field-by-field.","Check proxies/load balancers for idle timeouts that cut connections mid-packet."],"tags":["rust","network","tcp","protocol","truncated-data"],"backgroundTag":"unexpected-response-shape","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"}