{"record":{"id":"14ac3f093b05581e","repo":"nautechsystems/nautilus_trader","slug":"ax-fills-applied-limit-must-be-between-0-and-page","errorCode":null,"errorMessage":"AX fills applied limit must be between 0 and {PAGE_SIZE}, was {limit}","messagePattern":"AX fills 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":2231,"sourceCode":"        let mut seen_trade_ids = HashSet::new();\n        let mut seen_cursors = HashSet::new();\n        let mut expected_total = None;\n\n        loop {\n            let response = self\n                .inner\n                .get_fills_page(&params)\n                .await\n                .map_err(|e| anyhow::anyhow!(e))?;\n            let page_len = response.fills.len();\n\n            anyhow::ensure!(\n                page_len <= PAGE_SIZE as usize,\n                \"AX fills page length {page_len} exceeds requested limit {PAGE_SIZE}\"\n            );\n\n            if let Some(limit) = response.limit {\n                anyhow::ensure!(\n                    (0..=PAGE_SIZE).contains(&limit),\n                    \"AX fills applied limit must be between 0 and {PAGE_SIZE}, was {limit}\"\n                );\n                anyhow::ensure!(\n                    page_len <= limit as usize,\n                    \"AX fills page length {page_len} exceeds applied limit {limit}\"\n                );\n            }\n\n            if let Some(total_count) = response.total_count {\n                anyhow::ensure!(\n                    total_count >= 0,\n                    \"AX fills total_count must be non-negative, was {total_count}\"\n                );\n\n                if let Some(expected) = expected_total {\n                    anyhow::ensure!(\n                        total_count == expected,","sourceCodeStart":2213,"sourceCodeEnd":2249,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/architect_ax/src/http/client.rs#L2213-L2249","documentation":"The AX fills paginator validates that the `limit` field the server reports in each page response is within the legal range 0..=PAGE_SIZE. If the server echoes a limit outside that range (negative or larger than the max page size), the client refuses to trust it and aborts the fetch. This protects the paginator from applying an unbounded or nonsensical page size while paging through fills.","triggerScenarios":"Calling the AX fills pagination client method (client.rs paginate_fills loop) when the server response contains `limit` set to a value < 0 or > PAGE_SIZE (the client's maximum page size).","commonSituations":"A backend upgrade or misbehaving AX endpoint returns an oversized echo of the requested limit; a proxy rewrites the limit field; the client's PAGE_SIZE constant was reduced in a client update while the server still returns the old larger limit.","solutions":["Inspect the raw AX fills HTTP response body and check the `limit` field the server actually returns.","Confirm the server honors the limit you requested and caps it at PAGE_SIZE; file a bug with the AX service if it echoes a larger value.","Re-run with a smaller, explicitly-requested limit (<= PAGE_SIZE) so the server's applied limit stays in range.","Update the client to a version whose PAGE_SIZE matches the server's maximum page size."],"exampleFix":"// before: sending no explicit limit, letting server pick an out-of-range value\nlet page = client.fills(FillsParams { cursor, ..Default::default() }).await?;\n// after: pin the limit to PAGE_SIZE so the applied limit cannot exceed it\nlet page = client.fills(FillsParams { limit: Some(PAGE_SIZE), cursor, ..Default::default() }).await?;","handlingStrategy":"validation","validationCode":"// request only legal limits up front\nassert!((0..=PAGE_SIZE).contains(&params.limit.unwrap_or(PAGE_SIZE)), \"limit out of range\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always send an explicit limit <= PAGE_SIZE on fills requests.","Keep client PAGE_SIZE in sync with the server's documented max page size after upgrades.","Log raw response limit fields when debugging pagination."],"tags":["rust","pagination","validation","http-client"],"backgroundTag":"value-out-of-range","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"}