{"record":{"id":"84aae30a0ea9bffd","repo":"nautechsystems/nautilus_trader","slug":"instrument-ids-client-order-ids-and-venue-order","errorCode":null,"errorMessage":"instrument_ids, client_order_ids, and venue_order_ids must have the same length","messagePattern":"instrument_ids, client_order_ids, and venue_order_ids must have the same length","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/bybit/src/http/client.rs","lineNumber":2761,"sourceCode":"    /// # Errors\n    ///\n    /// Returns an error if:\n    /// - Credentials are missing.\n    /// - The request fails.\n    /// - Any of the orders don't exist.\n    /// - The API returns an error.\n    pub async fn batch_cancel_orders(\n        &self,\n        account_id: AccountId,\n        product_type: BybitProductType,\n        instrument_ids: Vec<InstrumentId>,\n        client_order_ids: Vec<Option<ClientOrderId>>,\n        venue_order_ids: Vec<Option<VenueOrderId>>,\n    ) -> anyhow::Result<Vec<OrderStatusReport>> {\n        if instrument_ids.len() != client_order_ids.len()\n            || instrument_ids.len() != venue_order_ids.len()\n        {\n            anyhow::bail!(\n                \"instrument_ids, client_order_ids, and venue_order_ids must have the same length\"\n            );\n        }\n\n        if instrument_ids.is_empty() {\n            return Ok(Vec::new());\n        }\n\n        let call_limit = batch_call_limit(product_type);\n        if instrument_ids.len() > call_limit {\n            anyhow::bail!(\n                \"Batch cancel limit is {call_limit} orders for {}\",\n                product_type.as_str()\n            );\n        }\n\n        let mut cancel_entries = Vec::new();\n","sourceCodeStart":2743,"sourceCodeEnd":2779,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/bybit/src/http/client.rs#L2743-L2779","documentation":"The batch cancel-all-orders path takes three parallel vectors (instrument IDs, client order IDs, venue order IDs) that must be index-aligned. The adapter validates equal lengths up front and bails otherwise, since misaligned vectors would mix identifiers across orders.","triggerScenarios":"Calling batch_cancel_all_orders with vectors of differing lengths, e.g. filling client_order_ids for some orders but not appending the corresponding None entries to venue_order_ids.","commonSituations":"Building the three lists in separate loops where skip conditions differ per list; deserializing request data where null entries were dropped from one list.","solutions":["Build the three vectors together in a single loop so they always stay the same length","Use Option entries (None) for orders lacking an identifier instead of omitting the element","Validate lengths before calling"],"exampleFix":"// before\nif let Some(cid) = client_id { client_ids.push(cid); }\nvenue_ids.push(vid); // lengths diverge\n// after\nclient_ids.push(client_id);\nvenue_ids.push(vid); // always paired pushes","handlingStrategy":"validation","validationCode":"anyhow::ensure!(instrument_ids.len() == client_order_ids.len() && instrument_ids.len() == venue_order_ids.len(), \"parallel vectors must be same length\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Build the three parallel vectors in one loop","Use None padding instead of omitting elements","Assert equal lengths in tests for batch helpers"],"tags":["bybit","batch-cancel","argument-validation"],"backgroundTag":"invalid-argument-value","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"}