{"record":{"id":"c049f7bc5f199e01","repo":"nautechsystems/nautilus_trader","slug":"ax-open-orders-applied-limit-must-be-between-0-and","errorCode":null,"errorMessage":"AX open-orders applied limit must be between 0 and {PAGE_SIZE}, was {}","messagePattern":"AX open-orders applied limit must be between 0 and (.+?), was (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/architect_ax/src/http/client.rs","lineNumber":2002,"sourceCode":"                .context(\"AX open-orders offset exceeds the documented int32 range\")?;\n            let params = GetOpenOrdersParams {\n                account_id: None,\n                limit: Some(PAGE_SIZE),\n                offset: Some(request_offset),\n                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())","sourceCodeStart":1984,"sourceCodeEnd":2020,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/architect_ax/src/http/client.rs#L1984-L2020","documentation":"A defensive check on a paginated open-orders response: the server-applied limit echoed in the page must lie in [0, PAGE_SIZE]. anyhow::ensure! fails the aggregation if AX claims to have applied a page size the client never requested, which would break the caller's offset/limit arithmetic. This signals an unexpected API response shape.","triggerScenarios":"Calling the paginated open-orders fetch when AX's response reports a limit that is negative or greater than the client's PAGE_SIZE — schema drift, response-field mismatch, or a gateway altering the payload.","commonSituations":"AX API upgrade changing the meaning or units of the limit field; responses from an incompatible AX environment (test vs prod) with different pagination semantics; mocked/stub responses used in local development.","solutions":["Verify the AX API contract for the open-orders page's limit field and update the client if semantics changed.","Log/dump the raw response page to inspect the returned limit.","Ensure the client and the deployed AX API version are compatible.","Check for proxies/interceptors rewriting response bodies."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// validate the echoed page limit yourself\nif response.limit < 0 || response.limit as usize > PAGE_SIZE {\n    return Err(anyhow!(\"AX page limit {} outside [0, {PAGE_SIZE}]\", response.limit));\n}","typeGuard":null,"tryCatchPattern":"match client.request_open_orders_paged().await {\n    Ok(orders) => orders,\n    Err(e) if e.to_string().contains(\"applied limit\") => {\n        tracing::error!(\"AX pagination semantics changed: {e:#}\");\n        Vec::new()\n    }\n    Err(e) => return Err(e),\n};","preventionTips":["Keep client PAGE_SIZE in sync with the AX API's allowed page size.","Diff response models against the AX OpenAPI spec on version bumps.","Test pagination against the real venue environment, not only mocks.","Log the raw page whenever an invariant fails."],"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"}