{"record":{"id":"5c61781235c252bd","repo":"nautechsystems/nautilus_trader","slug":"validated-above","errorCode":null,"errorMessage":"validated above","messagePattern":"validated above","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/bybit/src/execution.rs","lineNumber":1753,"sourceCode":"        let mut client_order_ids = Vec::with_capacity(valid_orders.len());\n\n        for order in &valid_orders {\n            let bybit_side = BybitOrderSide::from(order.order_side());\n            let position_idx = self.resolve_position_idx(\n                instrument_id,\n                bybit_side,\n                order.is_reduce_only(),\n                tp_sl.position_idx,\n            );\n            let params = Self::build_ws_place_params(\n                order,\n                product_type,\n                raw_symbol,\n                &tp_sl,\n                position_idx,\n                smp_type,\n            )\n            .expect(\"validated above\");\n            order_params.push(params);\n            client_order_ids.push(order.client_order_id());\n        }\n\n        let ws_trade = self.ws_trade.clone();\n        let dispatch_state = Arc::clone(&self.dispatch_state);\n\n        self.spawn_task(\"submit_order_list\", async move {\n            let req_ids = BybitWebSocketClient::batch_request_ids(product_type, order_params.len());\n            for (req_id, chunk_cids) in req_ids.iter().zip(\n                client_order_ids\n                    .chunks(batch_send_limit(product_type))\n                    .map(|chunk| chunk.to_vec()),\n            ) {\n                let chunk_voids = vec![None; chunk_cids.len()];\n                dispatch_state.pending_requests.insert(\n                    req_id.clone(),\n                    (chunk_cids, chunk_voids, PendingOperation::Place),","sourceCodeStart":1735,"sourceCodeEnd":1771,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/bybit/src/execution.rs#L1735-L1771","documentation":"In submit_order_list (live WebSocket batching), build_ws_place_params constructs the JSON payload per order. Its error cases were already filtered out when valid_orders was built, so the code expects success; a panic means the earlier filtering missed a case and validation drifted from payload construction.","triggerScenarios":"Submitting an order list where an order passes the pre-filter (e.g. valid order type/price/TIF combination) but build_ws_place_params still rejects it — typically after one of the two was changed without the other.","commonSituations":"Adding a new order type or TP/SL variant handled in the builder but not in the valid_orders filter (or vice versa); instrument-specific constraints (e.g. missing price for LIMIT) not checked upstream.","solutions":["Compare the valid_orders filtering logic with build_ws_place_params' error branches and align them","Handle the builder's Result explicitly and reject that order with an order-rejected event instead of panicking","Add a test per order type covering filter + builder together","Pin the adapter version known to match your order types; upgrade deliberately"],"exampleFix":"// before\nlet params = Self::build_ws_place_params(order, ...).expect(\"validated above\");\n// after\nlet params = Self::build_ws_place_params(order, ...)?; // or emit rejection for this order\norder_params.push(params);","handlingStrategy":"validation","validationCode":"// filter orders the same way build_ws_place_params does\nlet valid: Vec<_> = orders.into_iter()\n    .filter(|o| matches!(o.order_type(), OrderType::Limit | OrderType::Market))\n    .collect();","typeGuard":"fn is_submittable(order: &Order) -> bool {\n    matches!(order.order_type(), OrderType::Limit | OrderType::Market)\n        && order.order_side() != OrderSide::NoOrderSide\n        && !order.quantity().is_zero()\n}","tryCatchPattern":"let params = match Self::build_ws_place_params(order, ...) {\n    Ok(p) => p,\n    Err(e) => { emit_order_rejected(cid, e); continue; }\n};","preventionTips":["Keep the order filter and payload builder in lockstep; test them together","Cover every order type with an integration-style test","Prefer graceful per-order rejection over expect in submission paths"],"tags":["panic","invariant","order-submission","bybit","websocket"],"backgroundTag":"internal-invariant-violation","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"}