{"record":{"id":"6ae7bf13932fd413","repo":"nautechsystems/nautilus_trader","slug":"account-id-differs-across-fill-group","errorCode":null,"errorMessage":"account ID differs across fill group","messagePattern":"account ID differs across fill group","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/live/src/execution/manager.rs","lineNumber":1275,"sourceCode":"        ReconciliationResult {\n            events,\n            external_orders,\n        }\n    }\n\n    fn create_orphan_fill_order_report(\n        fills: &[&FillReport],\n        instrument: &InstrumentAny,\n    ) -> anyhow::Result<OrderStatusReport> {\n        let Some(first) = fills.first() else {\n            anyhow::bail!(\"fill group is empty\");\n        };\n        let venue_position_id = first\n            .venue_position_id\n            .ok_or_else(|| anyhow::anyhow!(\"venue position ID is missing\"))?;\n\n        for fill in fills.iter().skip(1) {\n            anyhow::ensure!(\n                fill.account_id == first.account_id,\n                \"account ID differs across fill group\"\n            );\n            anyhow::ensure!(\n                fill.instrument_id == first.instrument_id,\n                \"instrument ID differs across fill group\"\n            );\n            anyhow::ensure!(\n                fill.venue_order_id == first.venue_order_id,\n                \"venue order ID differs across fill group\"\n            );\n            anyhow::ensure!(\n                fill.client_order_id == first.client_order_id,\n                \"client order ID differs across fill group\"\n            );\n            anyhow::ensure!(\n                fill.order_side == first.order_side,\n                \"order side differs across fill group\"","sourceCodeStart":1257,"sourceCodeEnd":1293,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/live/src/execution/manager.rs#L1257-L1293","documentation":"create_orphan_fill_order_report validates that every fill in a group shares the same account_id as the first fill; this ensure! fires when fills from different accounts were grouped together. It is a consistency guard so the synthesized OrderStatusReport is unambiguous.","triggerScenarios":"Fill reports from two different account_ids sharing the same grouping key (e.g. same venue_order_id reused across accounts, or a grouping key that omits account_id).","commonSituations":"Multi-account setups where the venue reuses order IDs across accounts; adapters mixing fills from several accounts into one reconciliation batch; grouping-key bugs after config changes (e.g. account routing changes).","solutions":["Include account_id in the fill grouping key so groups never mix accounts.","Verify adapter/account configuration so fills are tagged with the correct account.","Audit venue behavior if the venue genuinely reuses order IDs across accounts.","Report as a bug if stock grouping logic mixes accounts."],"exampleFix":"// before\nlet group_key = (fill.venue_order_id, fill.instrument_id);\n// after\nlet group_key = (fill.account_id, fill.venue_order_id, fill.instrument_id);","handlingStrategy":"validation","validationCode":"anyhow::ensure!(fills.iter().all(|f| f.account_id == fills[0].account_id), \"mixed accounts in group\");","typeGuard":"fn single_account(fills: &[&FillReport]) -> bool { fills.iter().all(|f| f.account_id == fills.first().unwrap().account_id) }","tryCatchPattern":"if let Err(e) = create_orphan_fill_order_report(&fills, &instrument) { log::error!(\"fill group inconsistent: {e}\"); return; }","preventionTips":["Include account_id in every fill grouping key","Verify multi-account routing configuration","Audit adapters that batch fills across accounts"],"tags":["rust","fills","account-id","reconciliation"],"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-14T00:17:10.932Z"}