Pumpkin-MC/Pumpkin · warning · InventoryError

Player ' ' tried to interact with a closed container

Error message

Player '{0}' tried to interact with a closed container

What it means

This error is returned when a player attempts to interact with a container that is closed. The parameter is the player's entity ID, aiding logging and targeted responses. The library enforces that inventory interactions only occur on containers the player currently has open.

Solutions

  1. Ignore the interaction silently and close the player's container session, notifying the client with a CloseContainer packet
  2. Verify container open state before dispatching interaction handling
  3. Clear pending inventory packets for a session when the container closes
  4. If it occurs persistently, resynchronize the player's open-window state

Example fix

// before
container.handle_click(player_id, click)?;
// after
match container.handle_click(player_id, click) {
    Err(InventoryError::ClosedContainerInteract(id)) => {
        log::debug!("player {id} clicked a closed container; closing session");
        player.close_container();
    }
    r => r?,
}
Defensive patterns

Strategy: try-catch

Validate before calling

fn can_interact(session: &ContainerSession, player_id: i32) -> bool {
    session.is_open() && session.opened_by() == player_id
}

Try / catch

match container.handle_click(player_id, click) {
    Err(InventoryError::ClosedContainerInteract(id)) => {
        log::debug!("stale interaction from player {id}; closing session");
        player.close_container();
    }
    r => r?,
}

Prevention

When it happens

Trigger: Handling a click/drag packet whose window/session refers to a container that has since been closed — e.g. the container block was broken, the player moved away, or the container was closed server-side while packets were still in flight.

Common situations: Clients spamming clicks as a chest is broken; packets queued in the network buffer processed after close; desynchronized open/closed state between client and server after teleports.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


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

Appendix: source

Thrown at crates/pumpkin-inventory/src/error.rs:18

use thiserror::Error;

/// Errors that can occur during inventory operations.
///
/// These errors represent various failure conditions when handling inventory
/// interactions, such as invalid slot indices, permission issues, or protocol errors.
#[derive(Error, Debug)]
pub enum InventoryError {
    /// Failed to acquire a lock on an inventory or slot.
    #[error("Unable to lock")]
    LockError,
    /// The specified slot index is invalid or out of bounds.
    #[error("Invalid slot")]
    InvalidSlot,
    /// A player attempted to interact with a container that is closed.
    ///
    /// The parameter is the player's entity ID.
    #[error("Player '{0}' tried to interact with a closed container")]
    ClosedContainerInteract(i32),
    /// Multiple players attempted to drag items in the same container simultaneously.
    #[error("Multiple players dragging in a container at once")]
    MultiplePlayersDragging,
    /// Drag operation was performed out of order (e.g., end before start).
    #[error("Out of order dragging")]
    OutOfOrderDragging,
    /// The received inventory packet is malformed or invalid.
    #[error("Invalid inventory packet")]
    InvalidPacket,
    /// The player lacks permission to perform this inventory operation.
    #[error("Player does not have enough permissions")]
    PermissionError,
}

View on GitHub (pinned to 8d4639e25a)