nautechsystems/nautilus_trader · error

provider venue order {} repeats with contradictory evidence

Error message

provider venue order {} repeats with contradictory evidence

What it means

During order-status reconciliation, `selected_orders` maps venue_order_id to the accepted report. If the same venue order id is produced again, the earlier and current order snapshots must compare equal; a mismatch means the provider returned contradictory evidence for one venue order, so the adapter aborts reconciliation with `anyhow::ensure!` instead of guessing which snapshot is right.

Source

Thrown at crates/adapters/polymarket/src/execution/reconciliation.rs:1375

    load_ids: Option<&[InstrumentId]>,
) -> anyhow::Result<(Vec<OrderStatusReport>, usize)> {
    let mut reports = Vec::new();
    let mut filtered = 0usize;
    let mut selected_orders = AHashMap::new();

    for order in orders {
        let result = build_order_report_from_order(
            order,
            instruments,
            ctx,
            OrderEvidenceScope::Collection { instrument_filter },
            ts_init,
            load_ids,
        )?;

        if let Some(report) = result.report {
            if let Some(previous) = selected_orders.get(&report.venue_order_id) {
                anyhow::ensure!(
                    *previous == order,
                    "provider venue order {} repeats with contradictory evidence",
                    report.venue_order_id,
                );
                continue;
            }
            selected_orders.insert(report.venue_order_id, order);
            reports.push(report);
        } else {
            filtered += usize::from(result.counted_filtered);
        }
    }

    Ok((reports, filtered))
}

/// Applies time-range filters to fill reports.
pub(crate) fn apply_fill_time_filters(

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Log the diff between `*previous` and the new `order` snapshot to identify the diverging field, then re-fetch order reports in one consistent pass.
  2. Ensure each reconciliation run sources all order reports from a single query window so the venue order state cannot shift mid-run.
  3. Purge stale cached PolymarketOrderReport snapshots before reconciliation and rebuild from provider data.
  4. If the venue legitimately amends order history, upgrade the adapter to a version that resolves amended snapshots deterministically.

Example fix

// before: abort on divergent snapshots for one venue order
anyhow::ensure!(
    *previous == order,
    "provider venue order {} repeats with contradictory evidence",
    report.venue_order_id,
);
// after: keep the latest snapshot and log the divergence instead of failing the run
if let Some(previous) = selected_orders.get(&report.venue_order_id) {
    if *previous != order {
        log::warn!(
            "Venue order {} snapshot changed ({:?} -> {:?}); using latest",
            report.venue_order_id, previous, order,
        );
    }
}
selected_orders.insert(report.venue_order_id.clone(), order);
Defensive patterns

Strategy: validation

Validate before calling

let mut snapshots: AHashMap<Uuid, &PolymarketOrderReport> = AHashMap::new();
for order in fetched_order_reports() {
    if let Some(prev) = snapshots.get(&order.venue_order_id) {
        if *prev != order {
            return Err(anyhow::anyhow!(
                "venue order {} snapshot changed; re-fetch all order reports in one pass",
                order.venue_order_id,
            ));
        }
    } else {
        snapshots.insert(order.venue_order_id, order);
    }
}

Type guard

fn is_identical_snapshot(prev: &&PolymarketOrderReport, next: &PolymarketOrderReport) -> bool {
    *prev == next
}

Try / catch

match reconciliation_result {
    Err(e) if e.to_string().contains("provider venue order") => {
        log::warn!("order snapshot diverged mid-run; rebuilding from one consistent fetch");
        rebuild_order_reports();
    }
    other => other?,
}

Prevention

When it happens

Trigger: Calling Polymarket order status/fill report generation (the code path that loads per-venue-order results and inserts into `selected_orders`) when two fetched order snapshots for the same venue_order_id differ in any field (size, filled qty, status, price, timestamps) — e.g. data changed between two provider queries within one reconciliation run.

Common situations: Order state advanced (partially filled -> filled) between paginated/incremental provider fetches inside one reconciliation pass; stale cached report replayed alongside fresh data; venue retroactively corrected an order record; concurrent reconciliation runs merging different snapshots.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


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