{"record":{"id":"cb78979d2e8a9b86","repo":"nautechsystems/nautilus_trader","slug":"ax-open-orders-page-exceeds-total-count-next-offs","errorCode":null,"errorMessage":"AX open-orders page exceeds total_count: next offset {next_offset}, total {total_count}","messagePattern":"AX open-orders page exceeds total_count: next offset (.+?), total (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/architect_ax/src/http/client.rs","lineNumber":2030,"sourceCode":"\n            let total_count = *expected_total.get_or_insert(response.total_count);\n            anyhow::ensure!(\n                response.total_count == total_count,\n                \"AX open-orders total_count changed during pagination: expected {total_count}, was {}\",\n                response.total_count\n            );\n\n            let page_len = i64::try_from(response.orders.len())\n                .context(\"AX open-orders page length exceeds i64\")?;\n            anyhow::ensure!(\n                page_len <= i64::from(response.limit),\n                \"AX open-orders page length {page_len} exceeds applied limit {}\",\n                response.limit\n            );\n            let next_offset = offset\n                .checked_add(page_len)\n                .context(\"AX open-orders offset overflow\")?;\n            anyhow::ensure!(\n                next_offset <= total_count,\n                \"AX open-orders page exceeds total_count: next offset {next_offset}, total {total_count}\"\n            );\n\n            if total_count == 0 {\n                anyhow::ensure!(\n                    response.orders.is_empty(),\n                    \"AX open-orders returned rows with total_count zero\"\n                );\n                break;\n            }\n\n            anyhow::ensure!(\n                !response.orders.is_empty(),\n                \"AX open-orders returned an empty page before offset {offset} reached total {total_count}\"\n            );\n\n            for order in response.orders {","sourceCodeStart":2012,"sourceCodeEnd":2048,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/architect_ax/src/http/client.rs#L2012-L2048","documentation":"After each page, the client computes next_offset = offset + page_len and asserts it never exceeds total_count. A page that pushes the offset past the advertised total means the server returned more rows than it said exist, breaking the pagination contract and risking phantom/duplicated orders.","triggerScenarios":"A page's row count, accumulated from offset 0, exceeds the total_count the server reported, e.g. server returning overlapping pages or an inconsistent total.","commonSituations":"Venue-side pagination bugs; total_count shrinking while pages still return old rows; API version changes altering page semantics.","solutions":["Restart pagination from offset 0 to get a fresh consistent total","Verify request parameters (offset, limit) are sent as intended","Report the malformed pagination response to AX/adapter maintainers","Snapshot orders with a single large page if feasible to avoid multi-page arithmetic"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Validate before consuming: accumulated rows must never exceed the advertised total\nassert!(fetched_so_far + page.orders.len() as i64 <= page.total_count,\n    \"pagination would exceed total_count {}\", page.total_count);","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"page exceeds total_count\") => restart_pagination_from_zero(),\n    Err(e) => return Err(e),\n    Ok(orders) => use(orders),\n}","preventionTips":["Restart pagination from offset 0 on any consistency failure","Fetch a single large page when total_count is small","Report recurring mismatches to the venue — this usually indicates a server bug"],"tags":["pagination","http","offset-overflow"],"backgroundTag":"unexpected-api-response-shape","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"}