{"record":{"id":"230a49731a3bd28e","repo":"nautechsystems/nautilus_trader","slug":"fill-order-side-or-venue-order-id-differs-from","errorCode":null,"errorMessage":"fill {} order side or venue order ID differs from cached order","messagePattern":"fill (.+?) order side or venue order ID differs from cached order","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/live/src/execution/manager.rs","lineNumber":2834,"sourceCode":"        &self,\n        report: &mut FillReport,\n        venue_reports: &[PositionStatusReport],\n    ) -> anyhow::Result<PositionFillReportPreparation> {\n        let cache = self.cache.borrow();\n        let venue_client_order_id = cache.client_order_id(&report.venue_order_id).copied();\n        if let (Some(report_client_order_id), Some(venue_client_order_id)) =\n            (report.client_order_id, venue_client_order_id)\n        {\n            anyhow::ensure!(\n                report_client_order_id == venue_client_order_id,\n                \"fill {} client order ID {report_client_order_id} conflicts with venue order mapping {venue_client_order_id}\",\n                report.trade_id,\n            );\n        }\n        let client_order_id = report.client_order_id.or(venue_client_order_id);\n        let order = client_order_id.and_then(|id| cache.order(&id));\n        if let Some(order) = &order {\n            anyhow::ensure!(\n                order.instrument_id() == report.instrument_id\n                    && order.order_side() == report.order_side\n                    && order\n                        .account_id()\n                        .is_none_or(|account_id| account_id == report.account_id)\n                    && order\n                        .venue_order_id()\n                        .is_none_or(|venue_order_id| venue_order_id == report.venue_order_id),\n                \"fill {} conflicts with cached order {}\",\n                report.trade_id,\n                order.client_order_id(),\n            );\n        }\n\n        let hedge_context = report.venue_position_id.is_some()\n            || venue_reports\n                .iter()\n                .any(|venue_report| venue_report.venue_position_id.is_some());","sourceCodeStart":2816,"sourceCodeEnd":2852,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/live/src/execution/manager.rs#L2816-L2852","documentation":"After resolving the client_order_id, the manager looks up the cached order and verifies the fill report matches it on instrument_id, order_side, and account_id. A mismatch means the fill cannot belong to that cached order, so it aborts rather than corrupting position state.","triggerScenarios":"A fill report arrives for a cached client_order_id but with a different instrument_id, an opposite/other order_side, or a different account_id than the cached order records. Caused by adapter field mapping bugs, wrong instrument lookup, or reports routed to the wrong client account.","commonSituations":"Multi-account live setups where the adapter stamps the wrong account_id; symbol-mapping bugs that resolve the wrong instrument; venue side conventions (BUY/SELL) translated incorrectly by a custom adapter.","solutions":["Fix the adapter's field mapping so instrument_id, order_side, and account_id in reports match the submitted order","Verify instrument ID mapping/symbology resolves to the same nautilus instrument the order used","Check account_id assignment in the adapter's account-state/report handling","Re-reconcile the cached order if a legitimate order amendment changed its attributes"],"exampleFix":"// before (adapter hardcodes side)\nreport.order_side = OrderSide::Buy;\n// after\nreport.order_side = map_venue_side(venue_fill.side);","handlingStrategy":"validation","validationCode":"let order = cache.order(&client_order_id);\nif let Some(o) = order {\n    assert_eq!(o.instrument_id(), report.instrument_id);\n    assert_eq!(o.order_side(), report.order_side);\n}","typeGuard":"fn report_matches_order(report: &TradeReport, order: &OrderAny) -> bool {\n    order.instrument_id() == report.instrument_id\n        && order.order_side() == report.order_side\n        && order.account_id().map_or(true, |a| a == report.account_id)\n}","tryCatchPattern":null,"preventionTips":["Centralize side/instrument/account mapping in one adapter function used by all report types","Add adapter unit tests asserting mapped report fields equal submitted order fields","Use canonical nautilus instrument IDs derived from a single symbology table"],"tags":["rust","live-execution","report-conflict","order-mapping"],"backgroundTag":"internal-invariant-violation","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"}