{"record":{"id":"a7bf01638b7f928e","repo":"nautechsystems/nautilus_trader","slug":"order-client-order-id-not-found-in-cache","errorCode":null,"errorMessage":"Order {client_order_id} not found in cache.","messagePattern":"Order (.+?) not found in cache\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/execution/src/matching_engine/mod.rs","lineNumber":6325,"sourceCode":"\n    fn update_contingent_order(&mut self, order: &OrderAny, parent_quantity: Quantity) {\n        log::debug!(\n            \"Updating contingent orders from {}\",\n            order.client_order_id()\n        );\n\n        if let Some(linked_order_ids) = order.linked_order_ids() {\n            let parent_filled_qty = self\n                .cached_filled_qty\n                .get(&order.client_order_id())\n                .copied()\n                .unwrap_or(order.filled_qty());\n            let parent_leaves_qty = parent_quantity.saturating_sub(parent_filled_qty);\n\n            for client_order_id in linked_order_ids {\n                let child_order = match self.order_snapshot(*client_order_id) {\n                    Some(order) => order,\n                    None => panic!(\"Order {client_order_id} not found in cache.\"),\n                };\n\n                if child_order.is_active_local() {\n                    continue;\n                }\n\n                let child_filled_qty = self\n                    .cached_filled_qty\n                    .get(&child_order.client_order_id())\n                    .copied()\n                    .unwrap_or(child_order.filled_qty());\n\n                if parent_leaves_qty.is_zero() {\n                    self.cancel_order(&child_order, Some(false));\n                } else if child_filled_qty >= parent_leaves_qty {\n                    // Child already filled beyond parent's remaining qty, cancel it\n                    self.cancel_order(&child_order, Some(false));\n                } else {","sourceCodeStart":6307,"sourceCodeEnd":6343,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/execution/src/matching_engine/mod.rs#L6307-L6343","documentation":"While processing contingent-order bookkeeping for a parent order, the engine iterated linked_order_ids and found a linked child order missing from the cache (order_snapshot returned None), then panicked. Every order linked to a parent must be present in the engine cache for correct contingency lifecycle handling. Its absence means broken chain state or a stale ID.","triggerScenarios":"Executing the contingent-update path (near matching_engine/mod.rs:6325) where `for client_order_id in linked_order_ids` hits an ID with no cached snapshot.","commonSituations":"Cache evicted or never contained the child (e.g. child submitted on another node); cache lost on restart without persistence; stale linked_order_ids referencing long-finalized orders that were purged.","solutions":["Ensure all linked/child orders are submitted through the same node and remain in cache while the parent is active.","Enable cache persistence or rebuild contingency links during reconciliation after restart.","Purge parent and children together so stale IDs pointing to removed children do not linger.","Pre-check linked IDs against the cache before triggering the contingent update path."],"exampleFix":"// before\nengine.handle_event(&parent_filled_event); // triggers contingent update with stale links\n// after\nlet missing: Vec<_> = parent.linked_order_ids().unwrap_or_default()\n    .iter().filter(|id| cache.order(id).is_none()).collect();\nassert!(missing.is_empty(), \"uncached linked orders: {missing:?}\");","handlingStrategy":"validation","validationCode":"let missing: Vec<_> = parent.linked_order_ids().unwrap_or_default()\n    .iter().filter(|id| engine.order_snapshot(id).is_none()).collect();\nif !missing.is_empty() { return Err(anyhow!(\"linked orders not cached: {missing:?}\")); }","typeGuard":"fn all_links_cached(engine: &OrderMatchingEngine, order: &OrderAny) -> bool {\n    order.linked_order_ids().map_or(true, |ids| ids.iter().all(|id| engine.order_snapshot(id).is_some()))\n}","tryCatchPattern":null,"preventionTips":["Submit and track all linked child orders on the same node as the parent.","Enable cache persistence so chains survive restarts.","Purge parent and children together to avoid stale links.","Monitor for linked IDs absent from the cache as an early warning."],"tags":["rust","matching-engine","contingent-orders","cache","panic"],"backgroundTag":"entity-not-found","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}