nautechsystems/nautilus_trader · error
query_catalog_leg called with non-catalog-eligible variant {
Error message
query_catalog_leg called with non-catalog-eligible variant {leg:?} What it means
query_catalog_leg only knows how to query the catalog for catalog-eligible RequestCommand variants; any other variant reaching its catch-all arm is a programming error. The engine treats this as an internal invariant violation rather than a user-facing condition, since dispatch_date_range_request should have routed non-eligible variants elsewhere.
Source
Thrown at crates/data/src/engine/streaming.rs:512
))
}
RequestCommand::BookDepth(cmd) => {
let data: Vec<OrderBookDepth10> = catalog.order_book_depth10(
Some(vec![cmd.instrument_id.to_string()]),
Some(start_ns),
Some(end_ns),
)?;
Ok(build_book_depth_catalog_response(
cmd,
data,
start_ns,
end_ns,
used_client_id,
ts_init,
))
}
_ => {
anyhow::bail!("query_catalog_leg called with non-catalog-eligible variant {leg:?}")
}
}
}
fn dispatch_instrument_catalog_request(&mut self, req: RequestCommand) -> anyhow::Result<()> {
match req {
RequestCommand::Instrument(cmd) => self.dispatch_instrument_request(cmd),
RequestCommand::Instruments(cmd) => self.dispatch_instruments_request(cmd),
_ => self.dispatch_request_to_client(req).map(|_| ()),
}
}
fn dispatch_instrument_request(&mut self, cmd: RequestInstrument) -> anyhow::Result<()> {
let force_instrument_update = cmd
.params
.as_ref()
.and_then(|params| params.get_bool(PARAM_FORCE_INSTRUMENT_UPDATE))
.unwrap_or(false);View on GitHub (pinned to 18893faf8b)
Solutions
- Add a match arm in query_catalog_leg for the new variant that performs its catalog query
- Ensure non-catalog-eligible variants are filtered before reaching query_catalog_leg (they should dispatch straight to clients)
- Check request_identifier/dispatch routing so only catalog-eligible variants enter the catalog path
Example fix
// before
_ => anyhow::bail!("query_catalog_leg called with non-catalog-eligible variant {leg:?}")
// after
RequestCommand::MyNewRequest(r) => Ok(self.query_my_new_request_catalog(r, start_ns, end_ns, used_client_id, ts_init)),
_ => anyhow::bail!("query_catalog_leg called with non-catalog-eligible variant {leg:?}") Defensive patterns
Strategy: type-guard
Validate before calling
fn is_catalog_eligible(cmd: &RequestCommand) -> bool {
matches!(cmd, RequestCommand::QuoteTick(_) | RequestCommand::TradeTick(_) | RequestCommand::Bar(_) | RequestCommand::BookDeltas(_))
} Type guard
if !is_catalog_eligible(&req) { return dispatch_to_client_only(req); } Try / catch
match query_catalog_leg(...) { Err(e) if e.to_string().contains("non-catalog-eligible") => fallback_to_client(req), other => other? } Prevention
- When adding a RequestCommand variant, update query_catalog_leg, build_empty_response, and routing together
- Use exhaustive matches (no `_` arm) where feasible so the compiler flags new variants
- Route non-eligible variants before the catalog path in dispatch_date_range_request
When it happens
Trigger: A new RequestCommand variant is added and added to dispatch_date_range_request's identifier-based routing (request_identifier returns Some) but no catalog-leg match arm is written for it, so it falls through to the `_ =>` bail.
Common situations: Extending the data engine with a new request type during adapter development; refactoring the RequestCommand enum without updating query_catalog_leg's match; a bug routing an instrument request to the generic date-range path instead of dispatch_instrument_catalog_request.
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
- Cannot build empty catalog response for non-catalog-eligible
- RequestJoin must be handled by handle_request_join
- Cannot start bar aggregation for {bar_type}
- Account {account_id} not found after cache update
- No client registered with ID {client_id}
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/f82847b9ece00299.
Report an issue: GitHub.