{"record":{"id":"9b1bfd4f61e2a3ff","repo":"nautechsystems/nautilus_trader","slug":"invalid-venue-order-id-e","errorCode":null,"errorMessage":"Invalid venue order ID: {e}","messagePattern":"Invalid venue order ID: (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/futures/http/client.rs","lineNumber":2475,"sourceCode":"        client_order_id: Option<ClientOrderId>,\n    ) -> anyhow::Result<VenueOrderId> {\n        anyhow::ensure!(\n            venue_order_id.is_some() || client_order_id.is_some(),\n            \"Either venue_order_id or client_order_id must be provided\"\n        );\n\n        let symbol = format_binance_symbol(&instrument_id);\n\n        let order_id = match venue_order_id {\n            Some(venue_order_id) => match venue_order_id.inner().parse::<i64>() {\n                Ok(order_id) => Some(order_id),\n                Err(e) if client_order_id.is_some() => {\n                    log::warn!(\n                        \"Unable to parse venue_order_id {venue_order_id} for cancel, canceling by client_order_id: {e}\"\n                    );\n                    None\n                }\n                Err(e) => anyhow::bail!(\"Invalid venue order ID: {e}\"),\n            },\n            None => None,\n        };\n\n        let params = BinanceCancelOrderParams {\n            symbol,\n            order_id,\n            orig_client_order_id: client_order_id\n                .map(|id| encode_broker_id(&id, BINANCE_NAUTILUS_FUTURES_BROKER_ID)),\n            recv_window: None,\n        };\n\n        let order = self.inner.cancel_order(&params).await?;\n        Ok(VenueOrderId::new(order.order_id.to_string()))\n    }\n\n    /// Cancels an algo order (conditional order) via the Binance Algo Service.\n    ///","sourceCodeStart":2457,"sourceCodeEnd":2493,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/binance/src/futures/http/client.rs#L2457-L2493","documentation":"When canceling an order by venue_order_id, the adapter parses the venue ID into the format Binance expects. If parsing fails and no client_order_id fallback exists, it cannot construct a valid cancel request and bails with the parse error. If a client_order_id is present it logs a warning and falls back to cancel-by-client-order-id instead.","triggerScenarios":"Calling cancel_order with only a venue_order_id that is malformed, empty, or from a different venue/symbol (e.g. a Spot ID used against Futures), so BinanceOrderId::from_str fails.","commonSituations":"Cross-venue ID confusion after migrating a strategy between Binance Spot and Futures; corrupted or truncated venue order IDs stored in local state.","solutions":["Provide the client_order_id as well so the adapter can fall back to cancel-by-client-order-id","Verify the venue_order_id came from this Binance Futures venue and is intact","Check that the instrument_id matches the venue of the original order","Re-query the order by client_order_id to obtain the correct venue_order_id"],"exampleFix":"// before\nclient.cancel_order(instrument_id, None, Some(venue_order_id), None)\n// after\nclient.cancel_order(instrument_id, Some(client_order_id), Some(venue_order_id), None) // fallback available\n","handlingStrategy":"fallback","validationCode":"if let Some(vid) = venue_order_id { if BinanceOrderId::parse(vid).is_err() && client_order_id.is_none() { abort(\"need client_order_id fallback\"); } }","typeGuard":null,"tryCatchPattern":"match client.cancel_order(instrument_id, client_order_id, venue_order_id, None) { Err(e) if e.to_string().contains(\"Invalid venue order ID\") => cancel_by_client_order_id(), r => r }","preventionTips":["Always carry the client_order_id alongside venue_order_id","Sanity-check venue IDs come from the same venue as the client","Re-fetch venue IDs after adapter restarts"],"tags":["rust","binance","order-cancel","venue-order-id"],"backgroundTag":"invalid-identifier-format","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}