{"record":{"id":"df5d85a37a0a64b2","repo":"nautechsystems/nautilus_trader","slug":"cannot-modify-lighter-order-venue-order-id-not","errorCode":null,"errorMessage":"cannot modify Lighter order {}: venue order_id not yet known (await OrderAccepted before issuing modify)","messagePattern":"cannot modify Lighter order (.+?): venue order_id not yet known \\(await OrderAccepted before issuing modify\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/lighter/src/execution.rs","lineNumber":1930,"sourceCode":"        &self,\n        cmd: &ModifyOrder,\n        credential: &Credential,\n    ) -> anyhow::Result<PreparedModifyOrder> {\n        let market_index = self\n            .registry\n            .market_index(&cmd.instrument_id)\n            .ok_or_else(|| {\n                anyhow::anyhow!(\n                    \"no Lighter market_index registered for instrument {}\",\n                    cmd.instrument_id,\n                )\n            })?;\n\n        let voi = cmd\n            .venue_order_id\n            .or_else(|| self.dispatch.lookup_venue_order_id(&cmd.client_order_id))\n            .ok_or_else(|| {\n                anyhow::anyhow!(\n                    \"cannot modify Lighter order {}: venue order_id not yet known \\\n                     (await OrderAccepted before issuing modify)\",\n                    cmd.client_order_id,\n                )\n            })?;\n\n        let venue_index: i64 = voi\n            .as_str()\n            .parse()\n            .with_context(|| format!(\"Lighter venue_order_id `{voi}` is not an integer index\"))?;\n\n        let order = self.core.cache().try_order_owned(&cmd.client_order_id)?;\n        let instrument = self\n            .core\n            .cache()\n            .try_instrument(&cmd.instrument_id)?\n            .clone();\n","sourceCodeStart":1912,"sourceCodeEnd":1948,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/lighter/src/execution.rs#L1912-L1948","documentation":"Lighter identifies live orders by venue-assigned order_id, not by client_order_id. A modify request needs that venue id, which is only known after the submit has been acknowledged (OrderAccepted event). The adapter refuses the modify instead of sending a request Lighter could not match.","triggerScenarios":"Calling dispatch_signed_modify_order (or client.modify_order) with a ModifyOrder command whose venue_order_id is None and whose client_order_id is not yet in the dispatch's lookup map — i.e. the submit is still in flight or unacknowledged.","commonSituations":"Race after submitting: strategy fires the modify immediately after order.submit() before the websocket OrderAccepted arrives; rebasing/trailing-stop logic on tight timers; replaying a command batch where the submit never succeeded; connectivity drop so the ack never lands.","solutions":["Wait for the OrderAccepted event for the client_order_id before issuing the modify.","Check whether the original submit failed or is stuck; cancel/re-submit instead of modifying.","If the strategy must adjust quotes fast, treat the pre-ack window as a no-op and re-issue the modify once the venue order id is cached (verify with dispatch.lookup_venue_order_id)."],"exampleFix":"// before\nself.exec.modify_order(&modify_cmd).await?;\n// after\nif self.dispatch.lookup_venue_order_id(&modify_cmd.client_order_id).is_some() {\n    self.exec.modify_order(&modify_cmd).await?;\n} else {\n    // defer until OrderAccepted arrives\n}","handlingStrategy":"try-catch","validationCode":"fn can_modify(dispatch: &Dispatch, cmd: &ModifyOrder) -> bool {\n    cmd.venue_order_id.is_some()\n        || dispatch.lookup_venue_order_id(&cmd.client_order_id).is_some()\n}","typeGuard":null,"tryCatchPattern":"match client.modify_order(&cmd).await {\n    Err(e) if e.to_string().contains(\"venue order_id not yet known\") => defer_or_cancel(&cmd).await?,\n    r => r?,\n}","preventionTips":["Gate modifies on the OrderAccepted event, never on submit() returning.","Maintain a pending-modify queue keyed by client_order_id drained on OrderAccepted.","Log submit->ack latency to size the ack window in your strategy."],"tags":["order-modify","venue-order-id","race-condition","lighter"],"backgroundTag":"invalid-state-transition","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"}