nautechsystems/nautilus_trader · error
cached client order {} has no association with requested ven
Error message
cached client order {} has no association with requested venue order {venue_order_id} What it means
When the cached order has no venue_order_id of its own, the adapter still requires some association: the cached order's client order id must equal the requested client order id, or the registry must map the cached order's client order id to the requested venue order id. This ensure! fires when neither holds, meaning the cached order has no relationship at all to the requested venue order.
Source
Thrown at crates/adapters/polymarket/src/execution/reports.rs:146
self.order_contexts.venue_order_id(&client_order_id)
{
anyhow::ensure!(
registered_venue_order_id == venue_order_id,
"client order {client_order_id} is registered to venue order {registered_venue_order_id}, not requested venue order {venue_order_id}",
);
}
let cached_order = client_order_id.and_then(|value| self.core.cache().order_owned(&value));
if let Some(cached_order) = cached_order.as_ref() {
let cached_venue_order_id = cached_order.venue_order_id();
if let Some(cached_venue_order_id) = cached_venue_order_id {
anyhow::ensure!(
cached_venue_order_id == venue_order_id,
"cached client order {} is associated with venue order {cached_venue_order_id}, not requested venue order {venue_order_id}",
cached_order.client_order_id(),
);
} else {
anyhow::ensure!(
cached_client_order_id == client_order_id
|| self
.order_contexts
.venue_order_id(&cached_order.client_order_id())
== Some(venue_order_id),
"cached client order {} has no association with requested venue order {venue_order_id}",
cached_order.client_order_id(),
);
}
if let Some(requested_instrument_id) = requested_instrument_id {
anyhow::ensure!(
cached_order.instrument_id() == requested_instrument_id,
"cached order instrument {} does not match requested instrument {requested_instrument_id}",
cached_order.instrument_id(),
);
}
}View on GitHub (pinned to 18893faf8b)
Solutions
- Wait for submit acknowledgment so the cached order gains its venue_order_id before querying
- Query using the venue order's own registered client order id
- Check that the venue_order_id belongs to the order you intend
- Rebuild order_contexts registration if the registry lost the mapping
Example fix
// before
let reports = client.generate_fill_reports(Some(other_coid), venue_order_id).await?;
// after
if let Some(cached) = core.cache().order_owned(&coid) {
anyhow::ensure!(cached.venue_order_id().is_some(), "order not yet acknowledged by venue");
}
let reports = client.generate_fill_reports(Some(coid), venue_order_id).await?; Defensive patterns
Strategy: validation
Validate before calling
if let Some(cached) = core.cache().order_owned(&coid) {
anyhow::ensure!(cached.venue_order_id().is_some(), "order not yet acknowledged; defer fill query");
} Type guard
fn is_acknowledged(core: &Cache, coid: &ClientOrderId) -> bool {
core.order_owned(coid).map(|o| o.venue_order_id().is_some()).unwrap_or(false)
} Try / catch
match client.generate_fill_reports_impl(Some(coid), void_id).await {
Err(e) if e.to_string().contains("no association") => {
// order not yet linked; schedule retry after submit ack
}
other => other?,
} Prevention
- Only query fills after the order reaches an acknowledged/submitted state
- Gate fill-report generation on Submitted or later order events
- Keep submit -> ack -> query sequencing explicit in strategy logic
When it happens
Trigger: generate_fill_reports_impl or generate_order_status_report_impl called with a venue_order_id for an order whose cached client order is a different order and has not yet received a venue id (e.g. a pre-submit or unfilled order).
Common situations: Querying fills for a venue order before the cache learned its client-order linkage; strategy passing ids from two different orders; a partially initialized cache after restart.
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
- cached client order {} is associated with venue order {cache
- client order {client_order_id} is registered to venue order
- Cannot cancel order: {e}
- DataActor {} must be registered before calling `cache()` - t
- Order {client_order_id} not found
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/91948a600ba0dca8.
Report an issue: GitHub.