{"record":{"id":"1d5fd78e119f6c14","repo":"nautechsystems/nautilus_trader","slug":"ax-open-orders-response-offset-mismatch-requested","errorCode":null,"errorMessage":"AX open-orders response offset mismatch: requested {offset}, was {}","messagePattern":"AX open-orders response offset mismatch: requested (.+?), was (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/architect_ax/src/http/client.rs","lineNumber":2007,"sourceCode":"                sort_ts: Some(\"desc\".to_string()),\n            };\n            let response = self\n                .inner\n                .get_open_orders_page(&params)\n                .await\n                .map_err(|e| anyhow::anyhow!(e))?;\n\n            anyhow::ensure!(\n                response.total_count >= 0,\n                \"AX open-orders total_count must be non-negative, was {}\",\n                response.total_count\n            );\n            anyhow::ensure!(\n                response.limit >= 0 && response.limit <= PAGE_SIZE,\n                \"AX open-orders applied limit must be between 0 and {PAGE_SIZE}, was {}\",\n                response.limit\n            );\n            anyhow::ensure!(\n                i64::from(response.offset) == offset,\n                \"AX open-orders response offset mismatch: requested {offset}, was {}\",\n                response.offset\n            );\n\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","sourceCodeStart":1989,"sourceCodeEnd":2025,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/architect_ax/src/http/client.rs#L1989-L2025","documentation":"A defensive consistency check during open-orders pagination: the offset echoed by AX in the response must equal the offset the client requested. anyhow::ensure! aborts the loop on mismatch, because continuing would skip or duplicate orders. This catches venue-side pagination misbehavior or schema drift.","triggerScenarios":"Calling the paginated open-orders fetch when a returned page's offset differs from the requested offset — e.g. the venue clamped or reset the offset, or the response struct deserialized a different field into offset after an API change.","commonSituations":"AX paginating inconsistently under load; AX API version change to pagination semantics; stale client against an updated API; responses passing through a rewriting proxy.","solutions":["Log the requested vs returned offsets and the raw page to identify the divergence.","Verify the AX pagination contract (offset semantics, clamping) and update the client if needed.","Retry the full pagination from offset 0 to get a consistent snapshot.","Pin/align the adapter with the currently supported AX API version."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// verify offset echo before consuming the page\nif response.offset != requested_offset {\n    return Err(anyhow!(\"AX offset mismatch: requested {requested_offset}, got {}\", response.offset));\n}","typeGuard":null,"tryCatchPattern":"match client.request_open_orders_paged().await {\n    Ok(orders) => orders,\n    Err(e) if e.to_string().contains(\"offset mismatch\") => {\n        tracing::warn!(\"AX pagination desync, restarting from offset 0: {e:#}\");\n        restart_pagination_from_zero().await\n    }\n    Err(e) => return Err(e),\n};","preventionTips":["Restart pagination from offset 0 on any mismatch to get a consistent snapshot.","Keep the adapter aligned with the AX API's documented offset semantics.","Log requested vs returned offsets for venue bug reports.","Avoid mutating order state concurrently with full open-orders pagination where possible."],"tags":["pagination","schema","invariant","api-client"],"backgroundTag":"schema-validation-failed","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"}