{"record":{"id":"d0a929a9220fa10b","repo":"nautechsystems/nautilus_trader","slug":"orderlist-denied-duplicate","errorCode":null,"errorMessage":"OrderList denied: duplicate {}","messagePattern":"OrderList denied: duplicate (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/trading/src/strategy/mod.rs","lineNumber":272,"sourceCode":"            core.order_factory().create_list(&mut orders, ts_init)\n        };\n\n        if let Err(e) = order_list.validate() {\n            log::error!(\"OrderList denied: {e}\");\n            anyhow::bail!(\"OrderList denied: {e}\");\n        }\n\n        {\n            let cache_rc = core.cache_rc();\n            let mut cache = cache_rc.try_borrow_mut().map_err(|_| {\n                anyhow::anyhow!(\n                    \"Cannot submit order list {}: cache is currently borrowed\",\n                    order_list.id\n                )\n            })?;\n\n            if cache.order_list_exists(&order_list.id) {\n                anyhow::bail!(\"OrderList denied: duplicate {}\", order_list.id);\n            }\n\n            for order in &orders {\n                if cache.order_exists(&order.client_order_id()) {\n                    anyhow::bail!(\n                        \"Order in list denied: duplicate {}\",\n                        order.client_order_id()\n                    );\n                }\n            }\n\n            cache.add_order_list(order_list.clone())?;\n            for order in &orders {\n                cache.add_order(order.clone(), position_id, client_id, true)?;\n            }\n        }\n\n        for order in &orders {","sourceCodeStart":254,"sourceCodeEnd":290,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/trading/src/strategy/mod.rs#L254-L290","documentation":"The cache already contains an OrderList with the same list ID, so submit_order_list bails with 'OrderList denied: duplicate {id}'. Order list IDs must be unique per trading session; the cache rejects a second registration of the same list.","triggerScenarios":"Submitting an OrderList whose id already exists in the cache — resubmitting the same list object, or replaying a run where deterministic list IDs collide.","commonSituations":"Retry logic that resubmits the same list after an ambiguous failure; strategy restart/replay reusing factory IDs; constructing an OrderList manually with a fixed id.","solutions":["Create a new OrderList via the order factory so a fresh list ID is generated.","Check cache.order_list_exists(id) (or self.cache on the Python side) before submitting.","On retries after an error, assume the list may already be registered and use new orders/IDs instead of resubmitting."],"exampleFix":"// before\nself.submit_order_list(order_list)\n\n// after\nif not self.cache.order_list_exists(order_list.id):\n    self.submit_order_list(order_list)","handlingStrategy":"validation","validationCode":"if self.cache.order_list_exists(order_list.id):\n    self.log.warning(f\"order list {order_list.id} already registered; skipping\")\n    return","typeGuard":"def is_new_order_list(cache, order_list) -> bool:\n    return not cache.order_list_exists(order_list.id)","tryCatchPattern":"try:\n    self.submit_order_list(order_list)\nexcept RuntimeError as e:\n    if \"duplicate\" in str(e):\n        self.log.warning(f\"order list already in cache: {e}\")\n    else:\n        raise","preventionTips":["Check cache.order_list_exists before each submit_order_list call","Generate fresh lists via the order factory on retries instead of resubmitting the same object","Treat ambiguous submission failures as possibly-registered and use new IDs on retry"],"tags":["rust","strategy","duplicate","order-list","cache"],"backgroundTag":"duplicate-identifier","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"}