{"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":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/futures/http/client.rs","lineNumber":2381,"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":2363,"sourceCodeEnd":2399,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/a4b06ed870971b5671d12754ea138a3ab99b1dec/crates/adapters/binance/src/futures/http/client.rs#L2363-L2399","documentation":"Thrown by BinanceFuturesHttpClient::cancel_order when the supplied venue_order_id string cannot be parsed as an i64 and no client_order_id was provided as a fallback. Binance USD-M/Coin-M futures REST cancels key off a numeric orderId, so NautilusTrader parses VenueOrderId.inner() into i64; if parsing fails the client can only fall back to origClientOrderId, and with neither identifier usable it bails. The {e} suffix carries the underlying std::num::ParseIntError (e.g. 'invalid digit found in string').","triggerScenarios":"Calling cancel_order(instrument_id, Some(venue_order_id), None) where venue_order_id contains a non-numeric string (e.g. 'abc-123', an algo/conditional order ID, or an ID minted by another venue or a custom ClientOrderId scheme) or a number outside i64 range. The sibling branch (client_order_id.is_some()) logs a warning and falls back instead, so this exact error only fires when client_order_id is None.","commonSituations":"Porting a strategy from another venue and reusing VenueOrderIds from that venue; canceling a Binance 'Algo' (conditional) order through the regular cancel endpoint (algo orders use cancel_algo_order with client_algo_id); reconstructing VenueOrderId from a database where it was stored with decorations; empty-string or UUID-style IDs passed in integration glue code.","solutions":["Pass the client_order_id alongside the venue_order_id so the client can fall back to origClientOrderId when the parse fails","Verify the VenueOrderId actually originated from a Binance Futures execution report (it is always a decimal integer string) before calling cancel_order","If the target is a conditional/stop order, call cancel_algo_order(client_order_id) instead of cancel_order","Sanitize stored IDs before replay: strip prefixes/suffixes and confirm str::parse::<i64>() succeeds"],"exampleFix":"// before\nclient.cancel_order(instrument_id, Some(venue_order_id), None).await?;\n\n// after\nclient\n    .cancel_order(instrument_id, Some(venue_order_id), Some(client_order_id))\n    .await?;","handlingStrategy":"validation","validationCode":"fn is_binance_venue_id(id: &VenueOrderId) -> bool {\n    id.inner().parse::<i64>().is_ok()\n}\n\nif !is_binance_venue_id(&venue_order_id) && client_order_id.is_none() {\n    log::warn!(\"non-numeric venue order id {venue_order_id} with no client id fallback\");\n    return Ok(());\n}","typeGuard":"fn is_binance_venue_id(id: &VenueOrderId) -> bool {\n    id.inner().parse::<i64>().is_ok()\n}","tryCatchPattern":"Match on the anyhow message prefix \"Invalid venue order ID\" and surface a typed InvalidOrderId error to the caller; always pair venue_order_id with client_order_id so the library's built-in fallback path can engage.","preventionTips":["Always pass client_order_id together with venue_order_id to cancel_order","Never reuse VenueOrderId values originating from other venues or custom schemes","Store the raw numeric venue ID string exactly as returned in execution reports"],"tags":["binance","futures","order-cancel","venue-order-id","rust","nautilustrader"],"backgroundTag":"invalid-order-id","analyzedSha":"a4b06ed870971b5671d12754ea138a3ab99b1dec","analyzedAt":"2026-08-16T22:54:50.089Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}