{"record":{"id":"d37c5c94783d8498","repo":"bevyengine/bevy","slug":"tried-to-mutably-fetch-resource-with-id-0-whi","errorCode":null,"errorMessage":"Tried to mutably fetch resource with ID {0:?}, which is immutable","messagePattern":"Tried to mutably fetch resource with ID (.+?), which is immutable","errorType":"exception","errorClass":"ResourceFetchError::Immutable","httpStatus":null,"severity":"error","filePath":"crates/bevy_ecs/src/world/error.rs","lineNumber":77,"sourceCode":"    /// The entity with the given ID was requested mutably more than once.\n    #[error(\"The entity with ID {0} was requested mutably more than once\")]\n    AliasedMutability(Entity),\n}\n\n/// An error that occurs when getting a resource of a given type in a world.\n#[derive(thiserror::Error, Debug, Clone, Copy, PartialEq, Eq)]\npub enum ResourceFetchError {\n    /// The resource has never been initialized or registered with the world.\n    #[error(\"The resource has never been initialized or registered with the world. Did you forget to add it using `app.insert_resource` / `app.init_resource`?\")]\n    NotRegistered,\n    /// The resource with the given [`ComponentId`] does not currently exist in the world.\n    #[error(\"The resource with ID {0:?} does not currently exist in the world.\")]\n    DoesNotExist(ComponentId),\n    /// Cannot get access to the resource with the given [`ComponentId`] in the world as it conflicts with an on going operation.\n    #[error(\"Cannot get access to the resource with ID {0:?} in the world as it conflicts with an on going operation.\")]\n    NoResourceAccess(ComponentId),\n    /// Tried to mutably fetch an immutable resource.\n    #[error(\"Tried to mutably fetch resource with ID {0:?}, which is immutable\")]\n    Immutable(ComponentId),\n}\n\n#[cfg(test)]\nmod tests {\n    use crate::{\n        prelude::*,\n        system::{command::trigger, RunSystemOnce},\n    };\n\n    // Inspired by https://github.com/bevyengine/bevy/issues/19623\n    #[test]\n    fn fixing_panicking_entity_commands() {\n        #[derive(EntityEvent)]\n        struct Kill(Entity);\n\n        #[derive(EntityEvent)]\n        struct FollowupEvent(Entity);","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_ecs/src/world/error.rs#L59-L95","documentation":"ResourceFetchError::ImmutableResource: a mutable fetch (get_mut/resource_mut style access by id) was attempted on a resource declared with Resource<Mutability = Immutable>, so mutable access cannot be granted.","triggerScenarios":"Thrown at crates/bevy_ecs/src/world/error.rs:77 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fetch the resource immutably instead","Declare the resource as mutable (remove the Immutable mutability) if mutation is required","Replace the value wholesale via insert_resource rather than mutating it"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}