{"record":{"id":"c4b0dd0b6bf5b3ad","repo":"Pumpkin-MC/Pumpkin","slug":"player-0-tried-to-interact-with-a-closed-conta","errorCode":null,"errorMessage":"Player '{0}' tried to interact with a closed container","messagePattern":"Player '(.+?)' tried to interact with a closed container","errorType":"exception","errorClass":"InventoryError","httpStatus":null,"severity":"warning","filePath":"crates/pumpkin-inventory/src/error.rs","lineNumber":18,"sourceCode":"use thiserror::Error;\n\n/// Errors that can occur during inventory operations.\n///\n/// These errors represent various failure conditions when handling inventory\n/// interactions, such as invalid slot indices, permission issues, or protocol errors.\n#[derive(Error, Debug)]\npub enum InventoryError {\n    /// Failed to acquire a lock on an inventory or slot.\n    #[error(\"Unable to lock\")]\n    LockError,\n    /// The specified slot index is invalid or out of bounds.\n    #[error(\"Invalid slot\")]\n    InvalidSlot,\n    /// A player attempted to interact with a container that is closed.\n    ///\n    /// The parameter is the player's entity ID.\n    #[error(\"Player '{0}' tried to interact with a closed container\")]\n    ClosedContainerInteract(i32),\n    /// Multiple players attempted to drag items in the same container simultaneously.\n    #[error(\"Multiple players dragging in a container at once\")]\n    MultiplePlayersDragging,\n    /// Drag operation was performed out of order (e.g., end before start).\n    #[error(\"Out of order dragging\")]\n    OutOfOrderDragging,\n    /// The received inventory packet is malformed or invalid.\n    #[error(\"Invalid inventory packet\")]\n    InvalidPacket,\n    /// The player lacks permission to perform this inventory operation.\n    #[error(\"Player does not have enough permissions\")]\n    PermissionError,\n}\n","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/Pumpkin-MC/Pumpkin/blob/8d4639e25a57c15e47448ec327c780d41bbf2356/crates/pumpkin-inventory/src/error.rs#L1-L33","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ignore the interaction silently and close the player's container session, notifying the client with a CloseContainer packet","Verify container open state before dispatching interaction handling","Clear pending inventory packets for a session when the container closes","If it occurs persistently, resynchronize the player's open-window state"],"exampleFix":"// before\ncontainer.handle_click(player_id, click)?;\n// after\nmatch container.handle_click(player_id, click) {\n    Err(InventoryError::ClosedContainerInteract(id)) => {\n        log::debug!(\"player {id} clicked a closed container; closing session\");\n        player.close_container();\n    }\n    r => r?,\n}","handlingStrategy":"try-catch","validationCode":"fn can_interact(session: &ContainerSession, player_id: i32) -> bool {\n    session.is_open() && session.opened_by() == player_id\n}","typeGuard":null,"tryCatchPattern":"match container.handle_click(player_id, click) {\n    Err(InventoryError::ClosedContainerInteract(id)) => {\n        log::debug!(\"stale interaction from player {id}; closing session\");\n        player.close_container();\n    }\n    r => r?,\n}","preventionTips":["Check container open state before processing interaction packets","Close and clear pending packets for a session whenever a container closes","Send a CloseContainer packet so client and server state stay synchronized","Resynchronize open-window state after teleports or container breaks"],"tags":["inventory","container","state","protocol","rust"],"backgroundTag":"invalid-state-transition","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"}