{"record":{"id":"689bf42e6cbdb032","repo":"nautechsystems/nautilus_trader","slug":"invalid-venue-order-id-689bf4","errorCode":null,"errorMessage":"Invalid venue order ID","messagePattern":"Invalid venue order ID","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/spot/http/client.rs","lineNumber":3165,"sourceCode":"        &self,\n        account_id: AccountId,\n        instrument_id: InstrumentId,\n        venue_order_id: Option<VenueOrderId>,\n        client_order_id: Option<ClientOrderId>,\n    ) -> anyhow::Result<Option<OrderStatusReport>> {\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 = instrument_id.symbol.inner();\n        let instrument = self.instrument_from_cache(symbol)?;\n        let ts_init = self.generate_ts_init();\n\n        let order_id = venue_order_id\n            .map(|id| id.inner().parse::<i64>())\n            .transpose()\n            .map_err(|_| anyhow::anyhow!(\"Invalid venue order ID\"))?;\n\n        let client_id_str =\n            client_order_id.map(|id| encode_broker_id(&id, BINANCE_NAUTILUS_SPOT_BROKER_ID));\n\n        let order = match self\n            .inner\n            .query_order(symbol.as_str(), order_id, client_id_str.as_deref())\n            .await\n        {\n            Ok(order) => order,\n            Err(e) if Self::is_no_such_order_error(&e) => {\n                log::debug!(\"Binance Spot order not found: instrument_id={instrument_id}\");\n                return Ok(None);\n            }\n            Err(e) => anyhow::bail!(e),\n        };\n\n        parse_order_status_report_sbe(","sourceCodeStart":3147,"sourceCodeEnd":3183,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/binance/src/spot/http/client.rs#L3147-L3183","documentation":"NautilusTrader's Binance Spot adapter converts a VenueOrderId into the numeric i64 orderId that Binance's REST API expects. This error is thrown when the ID string cannot be parsed as an i64, meaning the ID does not look like a Binance order ID (which are positive integers). It guards query_order and related calls against sending malformed identifiers to the exchange.","triggerScenarios":"Calling query_order (or any method passing venue_order_id to it) with a VenueOrderId whose inner string is empty, non-numeric (e.g. a client-generated ID or UUID), negative, or exceeds the i64 range (e.g. >9223372036854775807).","commonSituations":"Passing a Nautilus ClientOrderId where a VenueOrderId is expected; using a venue order ID copied from a different exchange; formatting artifacts such as whitespace or quotes around the numeric ID; ID strings sourced from logs or third-party tools.","solutions":["Verify the VenueOrderId contains the numeric Binance orderId returned by place_order/cancel_order (response.order_id), not a client order ID.","Trim whitespace and ensure the ID string contains only digits before constructing the VenueOrderId.","If only a ClientOrderId is available, look it up first (e.g. via order cache or open_orders) to resolve the numeric venue order ID.","Check the ID fits in i64; Binance IDs are 64-bit but confirm the string was not truncated or padded in upstream storage."],"exampleFix":"// before\nlet venue_id = VenueOrderId::new(\"BTCUSDT_12345\"); // symbol-prefixed, not numeric\nclient.query_order(instrument_id, Some(venue_id), None).await?;\n// after\nlet venue_id = VenueOrderId::new(\"1234567890\"); // numeric Binance orderId\nassert!(venue_id.inner().parse::<i64>().is_ok());\nclient.query_order(instrument_id, Some(venue_id), None).await?;","handlingStrategy":"validation","validationCode":"fn is_valid_venue_order_id(id: &VenueOrderId) -> bool {\n    id.inner().trim().parse::<i64>().map(|v| v > 0).unwrap_or(false)\n}\n// call only if is_valid_venue_order_id(&id)","typeGuard":"fn valid_venue_order_id(id: &VenueOrderId) -> Option<i64> {\n    id.inner().parse::<i64>().ok().filter(|v| *v > 0)\n}","tryCatchPattern":"match client.query_order(instrument_id, Some(venue_id), None).await {\n    Ok(order) => { /* ... */ }\n    Err(e) if e.to_string().contains(\"Invalid venue order ID\") => {\n        log::warn!(\"non-numeric venue order id: {venue_id}\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Store the numeric response.order_id from order placement as the VenueOrderId, never the ClientOrderId.","Validate IDs parse as i64 at ingestion time, before they enter your cache or database.","Never hand-copy IDs from logs or other exchanges into VenueOrderId fields."],"tags":["parsing","order-id","binance-spot","validation"],"backgroundTag":"invalid-argument-format","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}