{"record":{"id":"ba8ad95fe2ff7626","repo":"nautechsystems/nautilus_trader","slug":"cannot-submit-an-empty-order-list","errorCode":null,"errorMessage":"Cannot submit an empty order list","messagePattern":"Cannot submit an empty order list","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/interactive_brokers/src/execution/core_orders.rs","lineNumber":422,"sourceCode":"        orders: &[OrderAny],\n        client: &Arc<Client>,\n        order_id_map: &Arc<Mutex<AHashMap<ClientOrderId, i32>>>,\n        venue_order_id_map: &Arc<Mutex<AHashMap<i32, ClientOrderId>>>,\n        instrument_id_map: &Arc<Mutex<AHashMap<i32, InstrumentId>>>,\n        trader_id_map: &Arc<Mutex<AHashMap<i32, TraderId>>>,\n        strategy_id_map: &Arc<Mutex<AHashMap<i32, StrategyId>>>,\n        active_order_contexts: &Arc<Mutex<AHashMap<i32, TrackedOrderContext>>>,\n        terminal_order_contexts: &Arc<Mutex<FifoCacheMap<i32, TrackedOrderContext, 10_000>>>,\n        next_order_id: &Arc<Mutex<i32>>,\n        instrument_provider: &Arc<InteractiveBrokersInstrumentProvider>,\n        exec_sender: &tokio::sync::mpsc::UnboundedSender<ExecutionEvent>,\n        clock: &'static AtomicTime,\n        account_id: AccountId,\n        strategy_id: StrategyId,\n        order_submit_lock: &Arc<tokio::sync::Mutex<()>>,\n    ) -> anyhow::Result<()> {\n        let num_orders = orders.len();\n        anyhow::ensure!(!orders.is_empty(), \"Cannot submit an empty order list\");\n\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();","sourceCodeStart":404,"sourceCodeEnd":440,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/interactive_brokers/src/execution/core_orders.rs#L404-L440","documentation":"handle_submit_order_list_async validates upfront that the batch it was asked to submit contains at least one order via anyhow::ensure!. An empty order list would produce zero IB child orders and no meaningful batch submission, so it is rejected before taking the order-submit lock.","triggerScenarios":"Calling handle_submit_order_list_async with an empty Vec of orders (e.g. a bracket/OCO batch builder that filtered out all orders, or a caller passing an unpopulated list).","commonSituations":"Strategy code building contingent order batches where all entries were dropped by conditional logic (e.g. every leg failed validation); refactors that moved filtering before batch construction.","solutions":["Guard the call site: skip calling handle_submit_order_list_async when orders.is_empty().","Fix the batch-construction logic so at least one order survives filtering.","Log the strategy state at the call site to see why the list ended up empty."],"exampleFix":"// before\nexec_client.handle_submit_order_list_async(orders, ...).await?;\n// after\nif !orders.is_empty() {\n    exec_client.handle_submit_order_list_async(orders, ...).await?;\n}","handlingStrategy":"validation","validationCode":"anyhow::ensure!(!orders.is_empty(), \"refusing to submit empty order batch\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Guard batch submission call sites with an is_empty check.","Log when batch construction filters out every order.","Unit-test batch builders with all-legs-filtered scenarios."],"tags":["interactive-brokers","empty-input","validation","rust"],"backgroundTag":"empty-required-field","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"}