{"record":{"id":"eb56501c9fc1bd52","repo":"nautechsystems/nautilus_trader","slug":"ax-fills-pagination-returned-unique-rows-expec","errorCode":null,"errorMessage":"AX fills pagination returned {} unique rows, expected {total_count}","messagePattern":"AX fills pagination returned (.+?) unique rows, expected (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/architect_ax/src/http/client.rs","lineNumber":2295,"sourceCode":"                        !next_cursor.is_empty(),\n                        \"AX fills returned an empty next_cursor\"\n                    );\n                    anyhow::ensure!(\n                        page_len > 0,\n                        \"AX fills returned an empty page with a next_cursor\"\n                    );\n                    anyhow::ensure!(\n                        seen_cursors.insert(next_cursor.clone()),\n                        \"AX fills pagination repeated cursor {next_cursor:?}\"\n                    );\n                    params.cursor = Some(next_cursor);\n                }\n                None => break,\n            }\n        }\n\n        if let Some(total_count) = expected_total {\n            anyhow::ensure!(\n                fills.len() as i64 == total_count,\n                \"AX fills pagination returned {} unique rows, expected {total_count}\",\n                fills.len()\n            );\n        }\n\n        let ts_init = self.generate_ts_init();\n        let mut reports = Vec::with_capacity(fills.len());\n\n        for fill in &fills {\n            let instrument = self.resolve_report_instrument(fill.symbol).await?;\n            let report = parse_fill_report(fill, account_id, &instrument, ts_init)\n                .with_context(|| format!(\"Failed to parse AX fill {}\", fill.trade_id))?;\n            reports.push(report);\n        }\n\n        Ok(reports)\n    }","sourceCodeStart":2277,"sourceCodeEnd":2313,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/architect_ax/src/http/client.rs#L2277-L2313","documentation":"At the end of pagination, if the server reported a total_count, the number of unique fills collected across all pages must equal it exactly. A shortfall means pages were missed or rows vanished mid-read, so the client aborts instead of returning an incomplete fill list.","triggerScenarios":"Pagination loop ended (next_cursor None) with fewer unique fills than the total_count reported on the first page — e.g. a page was truncated, or fills were deleted between page requests.","commonSituations":"Concurrent deletes/reconciliation removing fills while reading; a silently truncated final page; server counts rows before a filter the client-side window applies.","solutions":["Re-run the full pagination and compare; a transient concurrent mutation usually resolves.","Pin the query to a bounded, past time window so rows cannot disappear mid-read.","Log per-page lengths and the total_count to identify which page lost rows, then report to the AX backend team.","If fills are mutable by design, switch to an incremental/streaming fills feed rather than snapshot pagination."],"exampleFix":"// before: live window, rows can vanish mid-pagination\nlet params = FillsParams { start: Some(start), ..Default::default() };\n// after: closed snapshot window\nlet params = FillsParams { start: Some(start), end: Some(end), ..Default::default() };","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"match client.paginate_fills(params).await {\n    Ok(fills) => apply(fills),\n    Err(e) if e.to_string().contains(\"expected {total_count}\") || e.to_string().contains(\"unique rows, expected\") => {\n        warn!(\"incomplete fills snapshot; retrying once\");\n        client.paginate_fills(params).await\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Paginate over closed, past time windows to keep the row set immutable.","Avoid running fills pagination concurrently with deletes/reconciliation.","Log per-page counts to diagnose shortfalls quickly."],"tags":["rust","pagination","consistency","http-client"],"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-23T08:17:48.524Z"}