{"record":{"id":"2822aed28ee27999","repo":"nautechsystems/nautilus_trader","slug":"ax-open-orders-returned-rows-with-total-count-zero","errorCode":null,"errorMessage":"AX open-orders returned rows with total_count zero","messagePattern":"AX open-orders returned rows with total_count zero","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/architect_ax/src/http/client.rs","lineNumber":2036,"sourceCode":"            );\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 {\n                anyhow::ensure!(\n                    seen_order_ids.insert(order.oid.clone()),\n                    \"AX open-orders pagination returned duplicate order ID {}\",\n                    order.oid\n                );\n                orders.push(order);","sourceCodeStart":2018,"sourceCodeEnd":2054,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/architect_ax/src/http/client.rs#L2018-L2054","documentation":"When the venue advertises total_count of 0, the client requires the page to contain zero rows. Receiving rows alongside total_count=0 means the server's total is wrong, so the client refuses the response instead of trusting inconsistent metadata.","triggerScenarios":"The first open-orders page returns orders but reports total_count=0 — the server's count field disagrees with its payload.","commonSituations":"Newly placed orders not yet reflected in the venue's count; AX API bug or caching layer returning stale totals; adapter sending filters the server counts differently than it filters rows.","solutions":["Retry the request after a short delay so server-side counts catch up","Confirm the query filters sent match the API's documented semantics","Capture the raw response and report the inconsistent total to the venue","Trust rows over totals defensively only if you control the adapter fork"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if page.total_count == 0 && !page.orders.is_empty() {\n    // inconsistent; wait and refetch\n    std::thread::sleep(Duration::from_millis(200));\n    return fetch_open_orders();\n}","typeGuard":"fn is_consistent(total: i64, rows: usize) -> bool {\n    total > 0 || rows == 0\n}","tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"rows with total_count zero\") => {\n        tokio::time::sleep(Duration::from_millis(250)).await;\n        retry_fetch()\n    }\n    other => other,\n}","preventionTips":["Add a short backoff-and-retry around open-order polls","Ensure query filters match the API's documented counting semantics","Report persistent zero-total-with-rows responses to AX support"],"tags":["pagination","http","inconsistent-metadata"],"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-14T00:17:10.932Z"}