{"record":{"id":"23eeb93ca7faa3f9","repo":"nautechsystems/nautilus_trader","slug":"order-client-order-id-not-found","errorCode":null,"errorMessage":"Order {client_order_id} not found","messagePattern":"Order (.+?) not found","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/common/src/cache/mod.rs","lineNumber":5904,"sourceCode":"    }\n\n    /// Retrieves orders corresponding to the `client_order_ids`, optionally filtering by `side`.\n    ///\n    /// # Panics\n    ///\n    /// Panics if any `client_order_id` in the set is not found in the cache.\n    fn get_orders_for_ids(\n        &self,\n        client_order_ids: &AHashSet<ClientOrderId>,\n        side: Option<OrderSide>,\n    ) -> Vec<OrderRef<'_>> {\n        let mut orders = Vec::new();\n\n        for client_order_id in client_order_ids {\n            let order_cell = self\n                .orders\n                .get(client_order_id)\n                .unwrap_or_else(|| panic!(\"Order {client_order_id} not found\"));\n            let order = OrderRef::new(order_cell.borrow());\n\n            if side.is_none_or(|side| side == order.order_side()) {\n                orders.push(order);\n            }\n        }\n\n        // Sort so callers receive a deterministic Vec across runs; the\n        // underlying client_order_ids set is AHash-backed.\n        orders.sort_by_key(|o| o.client_order_id());\n        orders\n    }\n\n    /// Retrieves positions corresponding to the `position_ids`, optionally filtering by `side`.\n    ///\n    /// Each [`PositionRef`] in the returned vector borrows its underlying cell; mutating any of\n    /// those positions while the vector is alive will panic at runtime. Drop the vector before\n    /// issuing writes.","sourceCodeStart":5886,"sourceCodeEnd":5922,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/common/src/cache/mod.rs#L5886-L5922","documentation":"This panic occurs in the cache's bulk order fetch loop: for each id in client_order_ids it expects self.orders to contain an entry and panics otherwise via unwrap_or_else. The method is designed for callers that already hold guaranteed-valid order ids, so a missing id is treated as a programmer error.","triggerScenarios":"Calling the bulk order accessor with a client_order_id that was never created, that was purged from the cache, or that belongs to a different venue/backtest run.","commonSituations":"Reusing client order ids from a previous session or persisted log whose orders were evicted; a typo in the id; building an id list from external state (fills, orders.csv) not synchronized with the in-memory cache.","solutions":["Confirm every id in client_order_ids was created in this run and is still in the cache","Filter the id list against cache presence (e.g. a contains/order lookup returning Option) before the bulk fetch","Check for cache eviction/cleanup that removed orders referenced later","Log the offending client_order_id and verify it against the source that produced it"],"exampleFix":"// before\nlet ids: Vec<Ustr> = external_report_ids();\nlet orders = cache.orders(&ids, None);\n// after\nlet ids: Vec<Ustr> = external_report_ids()\n    .into_iter()\n    .filter(|id| cache.order(id).is_some())\n    .collect();\nlet orders = cache.orders(&ids, None);","handlingStrategy":"validation","validationCode":"let known: Vec<&Ustr> = client_order_ids\n    .iter()\n    .filter(|id| cache.order(id).is_some())\n    .collect();","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never feed ids from external artifacts (reports, old runs) directly into bulk cache accessors","Check cache membership before bulk fetch","Track cache resets and invalidate stored id lists"],"tags":["rust","cache","panic","order-not-found"],"backgroundTag":"record-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"}