nautechsystems/nautilus_trader · error · anyhow::Error

AX orders pagination repeated cursor {next_cursor:?}

Error message

AX orders pagination repeated cursor {next_cursor:?}

What it means

Cursor pagination must always move forward; the client records every next_cursor and aborts if the server hands back a cursor it already served. A repeated cursor would loop forever fetching the same page, so the guard converts an infinite loop into a clear error.

Source

Thrown at crates/adapters/architect_ax/src/http/client.rs:2150

        loop {
            let response = self
                .inner
                .get_orders(&params)
                .await
                .map_err(|e| anyhow::anyhow!(e))?;

            for order in response.orders {
                anyhow::ensure!(
                    seen_order_ids.insert(order.oid.clone()),
                    "AX orders pagination returned duplicate order ID {}",
                    order.oid
                );
                orders.push(order);
            }

            match response.next_cursor {
                Some(next_cursor) => {
                    anyhow::ensure!(
                        seen_cursors.insert(next_cursor.clone()),
                        "AX orders pagination repeated cursor {next_cursor:?}"
                    );
                    params.cursor = Some(next_cursor);
                }
                None => break,
            }
        }

        let ts_init = self.generate_ts_init();
        let mut reports = Vec::with_capacity(orders.len());

        for order in &orders {
            let instrument = self.resolve_report_instrument(order.s).await?;

            match parse_order_detail_status_report(
                order,
                account_id,

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Verify the adapter sends the cursor value unchanged (check for encoding/trimming bugs)
  2. Restart pagination from the beginning
  3. Increase page size to reduce reliance on cursor chaining
  4. Capture request/response pairs and report the stuck cursor to AX maintainers
Defensive patterns

Strategy: retry

Validate before calling

let mut seen_cursors = std::collections::HashSet::new();
if !seen_cursors.insert(next_cursor.clone()) {
    return Err(anyhow!("cursor loop detected: {next_cursor:?}"));
}

Try / catch

match result {
    Err(e) if e.to_string().contains("repeated cursor") => {
        warn!("AX cursor stuck; restarting pagination");
        restart_cursor_pagination()
    }
    other => other,
}

Prevention

When it happens

Trigger: Server returns a next_cursor identical to one previously returned, meaning it cannot advance past the current page — typically a server-side pagination bug or a corrupted/replayed cursor value.

Common situations: AX API pagination regression; cursor serialization issues in a proxy; adapter mutating the cursor string before sending it back.

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


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/a18d1bca7f8c5ce9. Report an issue: GitHub.