{"record":{"id":"4c639f32e6f57308","repo":"Pumpkin-MC/Pumpkin","slug":"failed-to-parse-json-into-game-profile","errorCode":null,"errorMessage":"Failed to parse JSON into Game Profile","messagePattern":"Failed to parse JSON into Game Profile","errorType":"exception","errorClass":"AuthError","httpStatus":null,"severity":"error","filePath":"crates/pumpkin/src/net/authentication.rs","lineNumber":405,"sourceCode":"        Err(AuthError::UnknownStatusCode(status))\n    } else {\n        Err(AuthError::FailedResponse)\n    }\n}\n\n#[derive(Error, Debug)]\npub enum AuthError {\n    #[error(\"Authentication servers are down\")]\n    FailedResponse,\n    #[error(\"Failed to verify username\")]\n    UnverifiedUsername,\n    #[error(\"You are banned from Authentication servers\")]\n    Banned,\n    #[error(\"Texture Error {0}\")]\n    TextureError(TextureError),\n    #[error(\"You have disallowed actions from Authentication servers\")]\n    DisallowedAction,\n    #[error(\"Failed to parse JSON into Game Profile\")]\n    FailedParse,\n    #[error(\"Unknown Status Code {0}\")]\n    UnknownStatusCode(StatusCode),\n}\n\n#[derive(Error, Debug)]\npub enum TextureError {\n    #[error(\"Invalid URL\")]\n    InvalidURL,\n    #[error(\"Invalid URL scheme for player texture: {0}\")]\n    DisallowedUrlScheme(String),\n    #[error(\"Invalid URL domain for player texture: {0}\")]\n    DisallowedUrlDomain(String),\n    #[error(\"Failed to decode base64 player texture: {0}\")]\n    DecodeError(String),\n    #[error(\"Failed to parse JSON from player texture: {0}\")]\n    JSONError(String),\n}","sourceCodeStart":387,"sourceCodeEnd":423,"githubUrl":"https://github.com/Pumpkin-MC/Pumpkin/blob/8d4639e25a57c15e47448ec327c780d41bbf2356/crates/pumpkin/src/net/authentication.rs#L387-L423","documentation":"PacketError::InvalidLength is raised by the RCON packet codec when a received buffer is too short to contain a valid RCON packet (length + id + type + body + padding). The codec rejects it before parsing fields. It indicates a truncated or non-RCON byte stream on the RCON connection.","triggerScenarios":"Reading from an RCON TCP stream that yields fewer bytes than the declared/minimum packet size; the length field itself cannot be read fully.","commonSituations":"An HTTP or other non-RCON client connecting to the RCON port; a truncated read due to connection drop mid-packet; a misconfigured proxy terminating the stream early.","solutions":["Verify the client connecting to the port actually speaks the RCON protocol.","Loop reads until the full declared length has been received instead of processing partial buffers.","Check for connection truncation (peer closed mid-packet) and reconnect.","Validate the read buffer length (>= 4 bytes for the length prefix, then >= declared length) before parsing."],"exampleFix":"// before\nlet len = i32::from_le_bytes(buf[0..4].try_into().unwrap());\n// after\nif buf.len() < 4 {\n    return Err(PacketError::InvalidLength);\n}\nlet len = i32::from_le_bytes(buf[0..4].try_into().unwrap());","handlingStrategy":"validation","validationCode":"fn has_min_rcon_header(buf: &[u8]) -> bool {\n    buf.len() >= 4\n}","typeGuard":"fn is_complete_rcon_packet(buf: &[u8]) -> bool {\n    if buf.len() < 4 { return false; }\n    let len = i32::from_le_bytes([buf[0], buf[1], buf[2], buf[3]]) as usize;\n    buf.len() >= 4 + len\n}","tryCatchPattern":"match rcon_conn.read_packet().await {\n    Err(PacketError::InvalidLength) => {\n        warn!(\"truncated/invalid RCON packet; reconnecting\");\n        rcon_conn = RconConnection::connect(addr).await?;\n    }\n    Ok(p) => handle(p),\n    Err(e) => warn!(\"rcon error: {e}\"),\n}","preventionTips":["Ensure only RCON-speaking clients can reach the RCON port.","Accumulate reads until the full declared packet length is buffered.","Handle peer disconnects mid-packet by reconnecting.","Sanity-check the length field against the buffer size before parsing."],"tags":["rcon","protocol","packet-framing","tcp"],"backgroundTag":"invalid-argument-format","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"}