nautechsystems/nautilus_trader · error

Failed to parse order report for {}: {e}

Error message

Failed to parse order report for {}: {e}

What it means

When reconciling via listCurrentOrders, each raw Betfair CurrentOrderSummary must be converted into an internal order report. If parse_current_order_report fails for a given bet_id, the client wraps the error with the bet id to identify the offending order.

Source

Thrown at crates/adapters/betfair/src/execution.rs:3827

            };

            let response = list_current_orders_with_retry(
                http_client,
                &params,
                stream_session,
                session_refresh,
            )
            .await?;
            let page_size = response.current_orders.len() as u32;

            if response.more_available && page_size == 0 {
                anyhow::bail!("listCurrentOrders returned an empty page with moreAvailable=true");
            }

            for order in &response.current_orders {
                let mut report =
                    parse_current_order_report(order, account_id, ts_init).map_err(|e| {
                        anyhow::anyhow!("Failed to parse order report for {}: {e}", order.bet_id)
                    })?;

                if let Some(resolution) = ocm_state.lock().resolve_order_owner(
                    order.customer_order_ref.as_deref(),
                    report.venue_order_id.as_str(),
                ) {
                    report.client_order_id = resolution.client_order_id();
                }

                let active_quantity = current_order_active_quantity(order).map_err(|e| {
                    anyhow::anyhow!("Failed to parse active quantity for {}: {e}", order.bet_id)
                })?;
                active_quantities.insert(order.bet_id.clone(), active_quantity);
                reports.push(report);
            }

            if !response.more_available {
                break;

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Log the raw CurrentOrderSummary JSON for the reported bet_id to see which field failed to parse.
  2. Update the parser (parse_current_order_report) to handle the new status/format encountered.
  3. Check for a nautilus_trader adapter update addressing Betfair API changes; retry reconciliation after transient issues.
Defensive patterns

Strategy: try-catch

Try / catch

match client.generate_order_status_reports().await {
    Ok(reports) => apply(reports),
    Err(e) if e.to_string().contains("Failed to parse order report") => {
        tracing::error!("reconciliation parse failure: {e:#}"); // inspect raw payload, upgrade adapter
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: A listCurrentOrders response contains a current order whose fields cannot be parsed (invalid price/size formats, unexpected order status, missing required fields) during reconciliation or generate_order_status_reports.

Common situations: Betfair API schema changes or new/unexpected order statuses; corrupted or unusual order state on the account; locale/formatting differences in numeric fields.

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/7ec43da712e54758. Report an issue: GitHub.