{"record":{"id":"ec6a5b62e04d4dc7","repo":"Pumpkin-MC/Pumpkin","slug":"json-error-0","errorCode":null,"errorMessage":"JSON error: {0}","messagePattern":"JSON error: (.+?)","errorType":"exception","errorClass":"AdvancementDataError","httpStatus":null,"severity":"error","filePath":"crates/pumpkin/src/entity/player/advancement.rs","lineNumber":247,"sourceCode":"    #[must_use]\n    pub(crate) const fn awarded(self) -> bool {\n        self.awarded\n    }\n\n    pub(crate) const fn combine(self, other: Self) -> Self {\n        Self {\n            awarded: self.awarded || other.awarded,\n            completed: self.completed || other.completed,\n        }\n    }\n}\n\n/// Errors that can occur when saving or loading advancement data.\n#[derive(Debug, thiserror::Error)]\npub enum AdvancementDataError {\n    #[error(\"IO error: {0}\")]\n    Io(std::io::Error),\n    #[error(\"JSON error: {0}\")]\n    Json(serde_json::Error),\n}\n\nimpl PlayerAdvancement {\n    /// Creates a new instance of `PlayerAdvancement`.\n    #[must_use]\n    pub fn new(manager: Arc<AdvancementManager>, uuid: Uuid) -> Self {\n        Self {\n            progress: AdvancementProgressMap::default(),\n            path: manager.advancement_path.join(format!(\"{uuid}.json\")),\n            manager,\n            player: Weak::new(),\n            is_first_packet: true,\n            roots_to_update: HashSet::default(),\n            visible: HashSet::default(),\n            progress_changed: HashSet::default(),\n            last_selected_tab: None,\n        }","sourceCodeStart":229,"sourceCodeEnd":265,"githubUrl":"https://github.com/Pumpkin-MC/Pumpkin/blob/8d4639e25a57c15e47448ec327c780d41bbf2356/crates/pumpkin/src/entity/player/advancement.rs#L229-L265","documentation":"PacketDecodeError::OutOfBounds is raised when the declared packet length is not within the valid bounds for decoding — typically a negative value, zero where data is required, or a length inconsistent with the remaining bytes in the buffer. The library validates the length before consuming the payload. It guards the decoder against impossible framing.","triggerScenarios":"Decoding a packet whose length VarInt decodes to a negative or otherwise invalid value; the declared length exceeds the bytes actually available in the read buffer.","commonSituations":"A truncated read (connection cut mid-packet) leaving fewer bytes than the declared length; corrupted or attacker-supplied length fields; a buggy client implementation producing malformed framing.","solutions":["Check that the full packet body is buffered before decoding (read length, then wait for len bytes).","Verify the connection was not closed/truncated mid-packet before interpreting the error.","Treat the peer as misbehaving and close the connection; framing cannot be trusted after OutOfBounds.","If parsing a captured/external byte stream, validate the length against buffer size before calling decode."],"exampleFix":"// before\nlet body = reader.read_exact(len as usize).await?; // len may exceed available bytes\n// after\nif len < 0 || len as usize > reader.remaining() {\n    return Err(PacketDecodeError::OutOfBounds);\n}\nlet body = reader.read_exact(len as usize).await?;","handlingStrategy":"validation","validationCode":"fn in_bounds(len: i32, available: usize) -> bool {\n    len > 0 && (len as usize) <= available\n}","typeGuard":"fn is_in_bounds(len: i64, available: usize) -> bool {\n    len > 0 && len <= available as i64\n}","tryCatchPattern":"match decode_packet(stream).await {\n    Err(PacketDecodeError::OutOfBounds) => { warn!(\"bad packet framing; closing connection\"); break; }\n    Ok(p) => handle(p),\n    Err(e) => warn!(\"decode error: {e}\"),\n}","preventionTips":["Buffer the full declared packet before decoding its body.","Check for EOF/truncation before interpreting framing errors.","Never cast a length to usize without checking it is positive and fits available data.","Treat framing violations as unrecoverable and close the connection."],"tags":["protocol","packet-decoding","bounds","network"],"backgroundTag":"value-out-of-range","analyzedSha":"8d4639e25a57c15e47448ec327c780d41bbf2356","analyzedAt":"2026-09-09T15:32:22.916Z","contentChangedAt":"2026-09-09T15:32:22.916Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}