Pumpkin-MC/Pumpkin · error · AuthError

Failed to parse JSON into Game Profile

Error message

Failed to parse JSON into Game Profile

What it means

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.

Solutions

  1. Verify the client connecting to the port actually speaks the RCON protocol.
  2. Loop reads until the full declared length has been received instead of processing partial buffers.
  3. Check for connection truncation (peer closed mid-packet) and reconnect.
  4. Validate the read buffer length (>= 4 bytes for the length prefix, then >= declared length) before parsing.

Example fix

// before
let len = i32::from_le_bytes(buf[0..4].try_into().unwrap());
// after
if buf.len() < 4 {
    return Err(PacketError::InvalidLength);
}
let len = i32::from_le_bytes(buf[0..4].try_into().unwrap());
Defensive patterns

Strategy: validation

Validate before calling

fn has_min_rcon_header(buf: &[u8]) -> bool {
    buf.len() >= 4
}

Type guard

fn is_complete_rcon_packet(buf: &[u8]) -> bool {
    if buf.len() < 4 { return false; }
    let len = i32::from_le_bytes([buf[0], buf[1], buf[2], buf[3]]) as usize;
    buf.len() >= 4 + len
}

Try / catch

match rcon_conn.read_packet().await {
    Err(PacketError::InvalidLength) => {
        warn!("truncated/invalid RCON packet; reconnecting");
        rcon_conn = RconConnection::connect(addr).await?;
    }
    Ok(p) => handle(p),
    Err(e) => warn!("rcon error: {e}"),
}

Prevention

When it happens

Trigger: Reading from an RCON TCP stream that yields fewer bytes than the declared/minimum packet size; the length field itself cannot be read fully.

Common situations: 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.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


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

Appendix: source

Thrown at crates/pumpkin/src/net/authentication.rs:405

        Err(AuthError::UnknownStatusCode(status))
    } else {
        Err(AuthError::FailedResponse)
    }
}

#[derive(Error, Debug)]
pub enum AuthError {
    #[error("Authentication servers are down")]
    FailedResponse,
    #[error("Failed to verify username")]
    UnverifiedUsername,
    #[error("You are banned from Authentication servers")]
    Banned,
    #[error("Texture Error {0}")]
    TextureError(TextureError),
    #[error("You have disallowed actions from Authentication servers")]
    DisallowedAction,
    #[error("Failed to parse JSON into Game Profile")]
    FailedParse,
    #[error("Unknown Status Code {0}")]
    UnknownStatusCode(StatusCode),
}

#[derive(Error, Debug)]
pub enum TextureError {
    #[error("Invalid URL")]
    InvalidURL,
    #[error("Invalid URL scheme for player texture: {0}")]
    DisallowedUrlScheme(String),
    #[error("Invalid URL domain for player texture: {0}")]
    DisallowedUrlDomain(String),
    #[error("Failed to decode base64 player texture: {0}")]
    DecodeError(String),
    #[error("Failed to parse JSON from player texture: {0}")]
    JSONError(String),
}

View on GitHub (pinned to 8d4639e25a)