{"record":{"id":"c1ef783433d7d025","repo":"nautechsystems/nautilus_trader","slug":"orderlist-from-orders-requires-first-order-to-hav","errorCode":null,"errorMessage":"OrderList::from_orders requires first order to have order_list_id","messagePattern":"OrderList::from_orders requires first order to have order_list_id","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/model/src/orders/list.rs","lineNumber":128,"sourceCode":"    /// and `strategy_id`. [`OrderList::validate`] checks the syntactic\n    /// invariants (non-empty, unique `client_order_ids`); it does not\n    /// check cross-field consistency.\n    ///\n    /// # Panics\n    ///\n    /// Panics if `orders` is empty, if the first order has no\n    /// `order_list_id`, or if orders span more than one venue. Callers\n    /// are expected to guard non-empty input; `Strategy::submit_order_list`\n    /// filters out the empty case and bails on mixed venues before\n    /// reaching this constructor.\n    #[must_use]\n    pub fn from_orders(orders: &[OrderAny], ts_init: UnixNanos) -> Self {\n        let first = orders\n            .first()\n            .expect(\"OrderList::from_orders requires non-empty orders\");\n        let order_list_id = first\n            .order_list_id()\n            .expect(\"OrderList::from_orders requires first order to have order_list_id\");\n        let instrument_id = first.instrument_id();\n        let strategy_id = first.strategy_id();\n        let venue = instrument_id.venue;\n\n        for order in orders {\n            assert!(\n                order.instrument_id().venue == venue,\n                \"OrderList::from_orders requires all orders to share the same venue; \\\n                 expected {venue}, found {} on {}\",\n                order.instrument_id().venue,\n                order.client_order_id(),\n            );\n        }\n\n        let client_order_ids = orders.iter().map(Order::client_order_id).collect();\n\n        Self {\n            id: order_list_id,","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/model/src/orders/list.rs#L110-L146","documentation":"OrderList::from_orders requires every order in the slice to carry an order_list_id, and reads it from the first order via an expect(). It panics when the first OrderAny was created without an order list id (typically standalone, non-list orders).","triggerScenarios":"Calling OrderList::from_orders on orders built individually (no OrderListId assigned via OrderListId::new / builder.order_list_id) — the first order's order_list_id() returns None.","commonSituations":"Mixing hand-built single orders into a batch that is later grouped into an OrderList; constructing orders via APIs that skip list-id assignment (contingent/standalone orders); migrating old persisted orders that predate list ids.","solutions":["Assign an OrderListId to every order before grouping, e.g. builder.order_list_id(order_list_id) with a shared OrderListId::new(...)","Filter the batch to only orders where order.order_list_id().is_some()","Group orders by their existing order_list_id and build one OrderList per id instead of mixing"],"exampleFix":"// before\nlet list = OrderList::from_orders(&orders, ts_init);\n// after\nlet list_id = OrderListId::new(\"OL-001\");\nlet orders: Vec<OrderAny> = orders\n    .into_iter()\n    .map(|o| o.with_order_list_id(list_id.clone())) // ensure id set at build time\n    .collect();\nlet list = OrderList::from_orders(&orders, ts_init);","handlingStrategy":"validation","validationCode":"// Rust\nif orders.first().and_then(|o| o.order_list_id()).is_none() {\n    // assign or reject before grouping\n}","typeGuard":"fn all_have_list_id(orders: &[OrderAny]) -> bool { orders.iter().all(|o| o.order_list_id().is_some()) }","tryCatchPattern":null,"preventionTips":["Assign a shared OrderListId at order-creation time via the builder","Group orders by order_list_id before constructing OrderLists","Never mix standalone orders into list batches"],"tags":["rust","panic","orders","identifier"],"backgroundTag":"missing-required-argument","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"}