{"record":{"id":"1f1e7ff8f302ae97","repo":"nautechsystems/nautilus_trader","slug":"component-id-not-found-in-global-registry","errorCode":null,"errorMessage":"Component '{id}' not found in global registry","messagePattern":"Component '(.+?)' not found in global registry","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/common/src/component.rs","lineNumber":715,"sourceCode":"}\n\n/// Releases subscriptions for a component in the global registry.\n///\n/// This is used when retiring a component whose earlier `on_dispose` failed after the framework\n/// left its registration intact.\n///\n/// # Errors\n///\n/// - Returns an error if the component is not found.\n/// - Returns an error if the component is already borrowed.\npub fn release_component_subscriptions(id: &Ustr) -> anyhow::Result<()> {\n    let component_ref = with_component_registry(|registry| {\n        let component_ref = registry\n            .get(id)\n            .ok_or_else(|| anyhow::anyhow!(\"Component '{id}' not found in global registry\"))?;\n\n        if !registry.try_borrow(*id) {\n            anyhow::bail!(\n                \"Component '{id}' is already mutably borrowed. \\\n                 This would create aliasing mutable references (undefined behavior).\"\n            );\n        }\n\n        Ok::<_, anyhow::Error>(component_ref)\n    })?;\n\n    let _guard = BorrowGuard::new(*id);\n\n    // SAFETY: Borrow tracking ensures exclusive access\n    unsafe {\n        let component = &mut *component_ref.get();\n        component.release_subscriptions();\n    }\n\n    Ok(())\n}","sourceCodeStart":697,"sourceCodeEnd":733,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/common/src/component.rs#L697-L733","documentation":"During teardown, `release_component_subscriptions` looks up a component by ID in the process-global component registry before releasing its subscriptions. The registry has no component registered under that UUID4, so the lookup fails and an anyhow error is returned. This indicates a component was disposed (or its ID fabricated) without ever being registered, or it was already removed by an earlier release/dispose pass.","triggerScenarios":"Calling dispose_registered_component -> release_component_subscriptions with a Component ID that was never inserted via the registry's registration path, was already removed, or whose ID string/UUID does not match any registered component (double-dispose, cloned stale ID, wrong actor/node).","commonSituations":"Double-disposal of the same component during shutdown; tearing down a node after a partial init failure where the component was never registered; reusing IDs across node restarts; copying component IDs from logs/config that belong to a different trader instance.","solutions":["Check that the component was created through the factory/registration path that inserts it into the global registry before disposal.","Guard against double disposal: track disposed component IDs and skip release_component_subscriptions if already released.","Verify the ID being passed is the component's own ID (UUID4), not a stale or hand-constructed value.","If teardown follows a failed init, ensure partial-failure cleanup only releases components that completed registration."],"exampleFix":"// before\ncomponent.unregister_all_subscriptions();\ndispose_registered_component(&component_id);\n\n// after\nif with_component_registry(|r| r.get(component_id).is_some()) {\n    dispose_registered_component(&component_id);\n} else {\n    log::debug!(\"component {component_id} not registered; skipping disposal\");\n}","handlingStrategy":"try-catch","validationCode":"let registered = with_component_registry(|r| r.get(&component_id).is_some());\nif !registered {\n    // skip disposal or log a warning\n}","typeGuard":"fn is_registered(id: &ComponentId) -> bool {\n    with_component_registry(|r| r.get(*id).is_some())\n}","tryCatchPattern":"match release_component_subscriptions(&component_id) {\n    Ok(_) => {}\n    Err(e) if e.to_string().contains(\"not found in global registry\") => {\n        log::warn!(\"component {} already absent; ignoring\", component_id);\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Only dispose components that were created through the registering factory path.","Track disposed IDs and make disposal idempotent.","Never hand-construct component IDs; always take them from the component instance."],"tags":["rust","registry","lifecycle","not-found"],"backgroundTag":"resource-not-found","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}