{"record":{"id":"b7a6ac22529b1bcb","repo":"nautechsystems/nautilus_trader","slug":"reason-b7a6ac","errorCode":null,"errorMessage":"{reason}","messagePattern":"\\{reason\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/deribit/src/execution.rs","lineNumber":1205,"sourceCode":"    }\n}\n\nfn reject_modify_command(\n    emitter: &ExecutionEventEmitter,\n    clock: &AtomicTime,\n    cmd: &ModifyOrder,\n    reason: &str,\n) -> anyhow::Result<()> {\n    let ts_event = clock.get_time_ns();\n    emitter.emit_order_modify_rejected_event(\n        cmd.strategy_id,\n        cmd.instrument_id,\n        cmd.client_order_id,\n        cmd.venue_order_id,\n        reason,\n        ts_event,\n    );\n    anyhow::bail!(\"{reason}\");\n}\n\n#[cfg(test)]\nmod tests {\n    use nautilus_common::messages::{ExecutionEvent, execution::ExecutionReport};\n    use nautilus_core::UUID4;\n    use nautilus_model::{\n        enums::{LiquiditySide, OrderSide},\n        events::OrderFilled,\n        identifiers::{ClientOrderId, InstrumentId, StrategyId, TradeId, TraderId, VenueOrderId},\n        types::{Currency, Money, Price, Quantity},\n    };\n    use rstest::rstest;\n\n    use super::*;\n\n    fn dispatch_test_rig() -> (\n        ExecutionEventEmitter,","sourceCodeStart":1187,"sourceCodeEnd":1223,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/deribit/src/execution.rs#L1187-L1223","documentation":"When modify_order receives a command it cannot honor, it emits a ModifyOrderRejected event to the engine and bails with the rejection reason itself as the message. The reason string comes from the caller's validation (e.g. unknown order, missing identifiers), so this error's text is entirely determined by that reason.","triggerScenarios":"Calling modify_order with a command lacking a resolvable venue_order_id/order, or any condition the client validates upfront that produces a rejection reason passed into this code path.","commonSituations":"Modifying an order the client never submitted (no venue_order_id mapping); commands replayed after a restart losing order state; malformed modify commands constructed upstream.","solutions":["Read the {reason} text — it states exactly why the modify was rejected","Ensure the order was submitted through this client so its venue_order_id is known","Do not attempt to modify orders after client restart without restoring order state","Guard upstream command construction so only orders with known venue state are modified"],"exampleFix":"// before\nclient.modify_order(&ModifyOrderCommand { client_order_id: unknown_id, ... }).await?;\n// after\nif let Some(venue_order_id) = client.venue_order_id_for(&unknown_id) {\n    client.modify_order(&ModifyOrderCommand { client_order_id: unknown_id, venue_order_id, ... }).await?;\n} else {\n    log::warn!(\"skipping modify: no venue_order_id known for {unknown_id}\");\n}","handlingStrategy":"validation","validationCode":"// Ensure the order is known to this client before modifying\nlet known = client.venue_order_id_for(&cmd.client_order_id).is_some()\n    || cmd.venue_order_id.is_some();\nif !known {\n    log::warn!(\"modify will be rejected: unknown order {}\", cmd.client_order_id);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only modify orders submitted through the same client instance","Persist order-state mappings (client_order_id -> venue_order_id) across restarts","Validate commands upstream so rejection reasons are rare","Treat the ModifyOrderRejected event, not just the error, as the authoritative signal"],"tags":["order-management","rejection","validation","deribit"],"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"}