{"record":{"id":"b4f24b6afe5760d2","repo":"nautechsystems/nautilus_trader","slug":"cannot-modify-order-without-venue-order-id","errorCode":null,"errorMessage":"Cannot modify order without venue_order_id","messagePattern":"Cannot modify order without venue_order_id","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/betfair/src/execution.rs","lineNumber":2441,"sourceCode":"                    );\n                }\n            }\n\n            Ok(())\n        });\n\n        Ok(())\n    }\n\n    fn modify_order(&self, cmd: ModifyOrder) -> anyhow::Result<()> {\n        self.process_pending_resync();\n\n        let instrument_id = cmd.instrument_id;\n        let market_id = extract_market_id(&instrument_id)?;\n\n        let venue_order_id = cmd\n            .venue_order_id\n            .ok_or_else(|| anyhow::anyhow!(\"Cannot modify order without venue_order_id\"))?;\n        let bet_id: BetId = venue_order_id.to_string();\n\n        // Compare against existing order to determine actual changes\n        let existing_order = self.core.get_order(&cmd.client_order_id);\n        let has_price_change = match (&cmd.price, &existing_order) {\n            (Some(new_price), Ok(order)) => order.price() != Some(*new_price),\n            (Some(_), Err(_)) => true,\n            (None, _) => false,\n        };\n        let has_quantity_change = match (&cmd.quantity, &existing_order) {\n            (Some(new_qty), Ok(order)) => order.quantity() != *new_qty,\n            (Some(_), Err(_)) => true,\n            (None, _) => false,\n        };\n\n        // Betfair does not support atomic price+quantity modification\n        if has_price_change && has_quantity_change {\n            let ts_event = self.clock.get_time_ns();","sourceCodeStart":2423,"sourceCodeEnd":2459,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/betfair/src/execution.rs#L2423-L2459","documentation":"Betfair orders are identified by a venue-assigned bet_id (VenueOrderId). Modifying an order requires that id because Betfair's placeOrders replacement flow targets existing bets by betId. The execution client throws this when a ModifyOrder command arrives without a venue_order_id, e.g. one generated before the order was acknowledged by the venue.","triggerScenarios":"Calling modify_order on a BetfairExecutionClient with a command whose cmd.venue_order_id is None — typically an order submitted but not yet confirmed by the venue, or a modification routed to the wrong client.","commonSituations":"Submitting a modify immediately after submit_order without waiting for the OrderAccepted/OrderUpdated event that carries the venue_order_id; replaying commands from persistence where the venue id was never persisted; using a client_order_id-only workflow.","solutions":["Wait for the order's venue_order_id (OrderAccepted event) before issuing ModifyOrder.","Verify the command targets the Betfair execution client that owns the order (get_order by client_order_id to confirm it exists and is acknowledged).","Cancel and resubmit the order with the desired price/quantity if the venue id is genuinely unavailable."],"exampleFix":"// before\nlet cmd = ModifyOrder::new(instrument_id, client_order_id, None, None, None);\nexec_client.modify_order(cmd)?; // panics/errors: no venue_order_id\n\n// after\nlet venue_order_id = portfolio.query_venue_order_id(&client_order_id)?; // after OrderAccepted\nlet cmd = ModifyOrder::new(instrument_id, client_order_id, Some(venue_order_id), Some(new_price), None);\nexec_client.modify_order(cmd)?;","handlingStrategy":"validation","validationCode":"if cmd.venue_order_id.is_none() {\n    return Err(anyhow!(\"refusing to modify order {}: no venue_order_id yet\", cmd.client_order_id));\n}","typeGuard":"fn is_modifiable(cmd: &ModifyOrder) -> bool { cmd.venue_order_id.is_some() }","tryCatchPattern":null,"preventionTips":["Only issue ModifyOrder after receiving the OrderAccepted event carrying venue_order_id.","Persist venue_order_id alongside client_order_id so replayed commands keep it.","Route commands to the execution client that owns the order."],"tags":["order-management","missing-identifier","betfair"],"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-23T08:17:48.524Z"}