{"record":{"id":"ccbcd5f038516448","repo":"nautechsystems/nautilus_trader","slug":"venue-order-id-required-for-query-order","errorCode":null,"errorMessage":"venue_order_id required for query_order","messagePattern":"venue_order_id required for query_order","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/deribit/src/execution.rs","lineNumber":796,"sourceCode":"                .request_account_state(account_id)\n                .await\n                .context(\"failed to query account state (check API credentials are valid)\")?;\n\n            emitter.send_account_state(account_state);\n            Ok(())\n        });\n\n        Ok(())\n    }\n\n    fn query_order(&self, cmd: QueryOrder) -> anyhow::Result<()> {\n        let ws_client = self.ws_client.clone();\n\n        // Extract venue order ID (Deribit's order_id)\n        let order_id = cmd\n            .venue_order_id\n            .as_ref()\n            .ok_or_else(|| anyhow::anyhow!(\"venue_order_id required for query_order\"))?\n            .to_string();\n\n        let client_order_id = cmd.client_order_id;\n        let trader_id = cmd.trader_id;\n        let strategy_id = cmd.strategy_id;\n        let instrument_id = cmd.instrument_id;\n\n        log::debug!(\"Querying order state: order_id={order_id}, client_order_id={client_order_id}\");\n\n        // Spawn async task to query order state via WebSocket\n        // Response will be dispatched through the WebSocket stream handler as OrderStatusReport\n        self.spawn_task(\"query_order\", async move {\n            ws_client\n                .query_order(\n                    &order_id,\n                    client_order_id,\n                    trader_id,\n                    strategy_id,","sourceCodeStart":778,"sourceCodeEnd":814,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/deribit/src/execution.rs#L778-L814","documentation":"Raised in `DeribitExecutionClient::query_order` when the `QueryOrder` command carries no `venue_order_id`. Deribit order state queries are keyed by the venue (Deribit) order_id, so the adapter refuses the request rather than guessing. It is a pre-flight argument validation error via `ok_or_else` on `cmd.venue_order_id`.","triggerScenarios":"Sending a `QueryOrder` command (e.g. via the trading kernel's `query_order` / a `QueryOrder` message) for an order that was never accepted by Deribit — hence has no venue_order_id assigned — or constructing the command manually without setting `venue_order_id`.","commonSituations":"Querying an order that was rejected before venue acknowledgement, querying a locally-generated order whose submit never completed, custom strategy code building QueryOrder with only `client_order_id`, or a race where the query fires before the `VenueOrderId` is assigned.","solutions":["Wait for the order-submit acknowledgement (which carries `venue_order_id`) before issuing query_order, or subscribe to order events instead.","Populate `cmd.venue_order_id` with the Deribit order_id before sending the command.","For orders known only by client_order_id, look up the venue id from prior order events or use a Deribit `get_order_state_by_label`-style path if the adapter supports it.","Guard caller code: skip or defer the query when `venue_order_id` is None."],"exampleFix":"// before\nbus.send(QueryOrder { instrument_id, client_order_id: Some(cid), venue_order_id: None, .. });\n\n// after\nif let Some(venue_order_id) = cache.venue_order_id(&client_order_id) {\n    bus.send(QueryOrder { instrument_id, client_order_id: Some(cid), venue_order_id: Some(venue_order_id), .. });\n}","handlingStrategy":"validation","validationCode":"// Rust, before issuing the command\nif cmd.venue_order_id.is_none() {\n    // defer query until the venue acknowledges the order\n    return Ok(());\n}","typeGuard":"fn has_venue_order_id(cmd: &QueryOrder) -> Option<VenueOrderId> {\n    cmd.venue_order_id\n}","tryCatchPattern":null,"preventionTips":["Only issue QueryOrder after receiving the order-submitted/accepted event that carries the VenueOrderId.","Keep an order cache mapping client_order_id -> venue_order_id from execution events.","For manual command construction, always populate venue_order_id for Deribit queries.","Prefer reacting to subscription order events over polling unknown orders."],"tags":["deribit","query-order","missing-argument","validation","execution-client"],"backgroundTag":"missing-required-argument","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"}