{"record":{"id":"f82847b9ece00299","repo":"nautechsystems/nautilus_trader","slug":"query-catalog-leg-called-with-non-catalog-eligible","errorCode":null,"errorMessage":"query_catalog_leg called with non-catalog-eligible variant {leg:?}","messagePattern":"query_catalog_leg called with non-catalog-eligible variant (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/data/src/engine/streaming.rs","lineNumber":512,"sourceCode":"                ))\n            }\n            RequestCommand::BookDepth(cmd) => {\n                let data: Vec<OrderBookDepth10> = catalog.order_book_depth10(\n                    Some(vec![cmd.instrument_id.to_string()]),\n                    Some(start_ns),\n                    Some(end_ns),\n                )?;\n                Ok(build_book_depth_catalog_response(\n                    cmd,\n                    data,\n                    start_ns,\n                    end_ns,\n                    used_client_id,\n                    ts_init,\n                ))\n            }\n            _ => {\n                anyhow::bail!(\"query_catalog_leg called with non-catalog-eligible variant {leg:?}\")\n            }\n        }\n    }\n\n    fn dispatch_instrument_catalog_request(&mut self, req: RequestCommand) -> anyhow::Result<()> {\n        match req {\n            RequestCommand::Instrument(cmd) => self.dispatch_instrument_request(cmd),\n            RequestCommand::Instruments(cmd) => self.dispatch_instruments_request(cmd),\n            _ => self.dispatch_request_to_client(req).map(|_| ()),\n        }\n    }\n\n    fn dispatch_instrument_request(&mut self, cmd: RequestInstrument) -> anyhow::Result<()> {\n        let force_instrument_update = cmd\n            .params\n            .as_ref()\n            .and_then(|params| params.get_bool(PARAM_FORCE_INSTRUMENT_UPDATE))\n            .unwrap_or(false);","sourceCodeStart":494,"sourceCodeEnd":530,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/data/src/engine/streaming.rs#L494-L530","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\n_ => anyhow::bail!(\"query_catalog_leg called with non-catalog-eligible variant {leg:?}\")\n// after\nRequestCommand::MyNewRequest(r) => Ok(self.query_my_new_request_catalog(r, start_ns, end_ns, used_client_id, ts_init)),\n_ => anyhow::bail!(\"query_catalog_leg called with non-catalog-eligible variant {leg:?}\")","handlingStrategy":"type-guard","validationCode":"fn is_catalog_eligible(cmd: &RequestCommand) -> bool {\n    matches!(cmd, RequestCommand::QuoteTick(_) | RequestCommand::TradeTick(_) | RequestCommand::Bar(_) | RequestCommand::BookDeltas(_))\n}","typeGuard":"if !is_catalog_eligible(&req) { return dispatch_to_client_only(req); }","tryCatchPattern":"match query_catalog_leg(...) { Err(e) if e.to_string().contains(\"non-catalog-eligible\") => fallback_to_client(req), other => other? }","preventionTips":["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"],"tags":["rust","internal-invariant","match-arm","data-engine"],"backgroundTag":"internal-invariant-violation","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}