nautechsystems/nautilus_trader · error · anyhow::Error
AX open-orders returned an empty page before offset
Error message
AX open-orders returned an empty page before offset {offset} reached total {total_count} What it means
During offset pagination, a mid-stream empty page before reaching total_count means rows are missing: the server advertised more orders than it will ever return at the current offsets. The client fails fast rather than silently returning fewer orders than the venue promised.
Solutions
- Retry the full pagination from offset 0
- Re-check whether the orders were legitimately canceled mid-poll (expected churn, not a bug)
- Verify the adapter's offset/limit parameters against current AX API docs
- Increase page size to reduce the number of pages and the window for churn
Defensive patterns
Strategy: retry
Validate before calling
if offset < total_count && page.orders.is_empty() {
return Err(anyhow!("empty page at offset {offset}, total {total_count}"));
} Try / catch
match result {
Err(e) if e.to_string().contains("empty page before offset") => restart_pagination(),
Err(e) => return Err(e),
Ok(orders) => use(orders),
} Prevention
- Expect mid-poll cancellations on active accounts and retry the full loop
- Increase page size to reduce page count and churn exposure
- Verify offset/limit parameters against current AX API docs
When it happens
Trigger: Server returns an empty orders array while offset < total_count, e.g. rows were removed server-side after the total was computed, or a page boundary bug skips rows.
Common situations: Orders canceled during pagination; venue soft-deleting rows without adjusting totals; API pagination endpoint regression.
Understand the failure class
Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — this error's family across 23 libraries.
Related errors
- AX fills page length
- AX open-orders page exceeds total_count: next offset
- AX open-orders page length
- AX open-orders pagination did not return the advertised…
- AX open-orders pagination returned duplicate order ID
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/9687430e00451492.
Report an issue: GitHub.
Appendix: source
Thrown at crates/adapters/architect_ax/src/http/client.rs:2043
response.limit
);
let next_offset = offset
.checked_add(page_len)
.context("AX open-orders offset overflow")?;
anyhow::ensure!(
next_offset <= total_count,
"AX open-orders page exceeds total_count: next offset {next_offset}, total {total_count}"
);
if total_count == 0 {
anyhow::ensure!(
response.orders.is_empty(),
"AX open-orders returned rows with total_count zero"
);
break;
}
anyhow::ensure!(
!response.orders.is_empty(),
"AX open-orders returned an empty page before offset {offset} reached total {total_count}"
);
for order in response.orders {
anyhow::ensure!(
seen_order_ids.insert(order.oid.clone()),
"AX open-orders pagination returned duplicate order ID {}",
order.oid
);
orders.push(order);
}
if next_offset == total_count {
break;
}
offset = next_offset;View on GitHub (pinned to 18893faf8b)