{"record":{"id":"da4e90ea71c6e515","repo":"nautechsystems/nautilus_trader","slug":"parent-order-id-parent-order-id-not-found-for-or","errorCode":null,"errorMessage":"Parent order ID {parent_order_id} not found for order {}","messagePattern":"Parent order ID (.+?) not found for order (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/interactive_brokers/src/execution/core_orders.rs","lineNumber":441,"sourceCode":"\n        let _submit_guard = order_submit_lock.lock().await;\n        let ib_account = account_id\n            .to_string()\n            .split_once('-')\n            .map_or_else(|| account_id.to_string(), |(_, value)| value.to_string());\n        let mut ib_order_ids = AHashMap::with_capacity(num_orders);\n\n        for order in orders {\n            let ib_order_id = Self::reserve_next_local_order_id(next_order_id)?;\n            ib_order_ids.insert(order.client_order_id(), ib_order_id);\n        }\n\n        for order in orders {\n            if let Some(parent_order_id) = order.parent_order_id()\n                && !ib_order_ids.contains_key(&parent_order_id)\n            {\n                let map = order_id_map.lock();\n                anyhow::ensure!(\n                    map.contains_key(&parent_order_id),\n                    \"Parent order ID {parent_order_id} not found for order {}\",\n                    order.client_order_id(),\n                );\n            }\n        }\n\n        for (index, order) in orders.iter().enumerate() {\n            let is_last = index == num_orders - 1;\n            let ib_order_id = ib_order_ids[&order.client_order_id()];\n\n            let order_contract =\n                Self::resolve_contract_for_instrument(order.instrument_id(), instrument_provider)?;\n            let order_contract =\n                Self::contract_with_order_exchange_param(order_contract, cmd.params.as_ref())?;\n\n            let order_ref = order.client_order_id().to_string();\n            let mut ib_order = nautilus_order_to_ib_order(","sourceCodeStart":423,"sourceCodeEnd":459,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/interactive_brokers/src/execution/core_orders.rs#L423-L459","documentation":"When submitting a batch, child orders may reference a parent_order_id. The parent must either be another order in the same batch (present in ib_order_ids) or a previously submitted order known to the adapter's order_id_map. If the parent ID is in neither, this ensure! fires — the parent relationship cannot be resolved for the IB batch submission.","triggerScenarios":"Submitting an order whose parent_order_id() was never submitted (or was submitted with a different client_order_id than the one stored in order_id_map), within handle_submit_order_list_async.","commonSituations":"Bracket/OCO setups where the parent leg failed or was rejected earlier; using stale or regenerated ClientOrderIds after a node restart that cleared order_id_map; typo'd or swapped parent/child IDs.","solutions":["Ensure the parent order is submitted (and accepted) before submitting the child, or include the parent in the same batch.","Verify the child's parent_order_id matches the parent's actual ClientOrderId exactly.","If the parent was submitted in a prior session, resubmit it or clear the child's parent reference.","Check that order_id_map is persistent/populated as expected after restarts."],"exampleFix":"// before\nlet child = build_bracket_leg(parent_id: some_stale_id, ...);\n// after\nlet child = build_bracket_leg(parent_id: parent_client_order_id, ...); // must match a live/submitted order","handlingStrategy":"validation","validationCode":"if let Some(parent_id) = order.parent_order_id() {\n    anyhow::ensure!(submitted_ids.contains(&parent_id), \"parent {} not yet submitted\", parent_id);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always submit parent orders (or include them in the same batch) before children.","Persist or rebuild order_id_map across restarts before resuming contingent orders.","Assert parent/child ID consistency when building bracket orders."],"tags":["interactive-brokers","order-list","parent-order","not-found","rust"],"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-14T05:17:10.506Z"}