{"record":{"id":"e5b5db0c215c6dda","repo":"nautechsystems/nautilus_trader","slug":"instrument-instrument-id-not-found-and-auto-loa-e5b5db","errorCode":null,"errorMessage":"Instrument {instrument_id} not found and `auto_load_missing_instruments` is disabled","messagePattern":"Instrument (.+?) not found and `auto_load_missing_instruments` is disabled","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/derive/src/data.rs","lineNumber":542,"sourceCode":"        for instrument in instruments {\n            self.cache_instrument(&instrument);\n            if let Err(e) = self.data_sender.send(DataEvent::Instrument(instrument)) {\n                log::warn!(\"Failed to send Derive instrument: {e}\");\n            }\n        }\n    }\n\n    fn cache_instrument(&self, instrument: &InstrumentAny) {\n        cache_instrument(&self.instruments, instrument);\n    }\n\n    fn prepare_subscribe(&self, instrument_id: InstrumentId) -> anyhow::Result<bool> {\n        if self.instruments.contains_key(&instrument_id) {\n            return Ok(false);\n        }\n\n        if !self.config.auto_load_missing_instruments {\n            anyhow::bail!(\n                \"Instrument {instrument_id} not found and `auto_load_missing_instruments` is disabled\"\n            );\n        }\n        Ok(true)\n    }\n\n    async fn lazy_load_instrument(\n        http_client: DeriveHttpClient,\n        instruments: Arc<AtomicMap<InstrumentId, InstrumentAny>>,\n        instrument_id: InstrumentId,\n        include_expired: bool,\n    ) -> anyhow::Result<()> {\n        let currency = currency_from_instrument_id(&instrument_id)?;\n        let definitions = fetch_instrument_definitions(&http_client, currency, include_expired)\n            .await\n            .with_context(|| format!(\"failed to lazy-load Derive instruments for {currency}\"))?;\n        let mut found = false;\n","sourceCodeStart":524,"sourceCodeEnd":560,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/derive/src/data.rs#L524-L560","documentation":"Raised by `prepare_subscribe` when a subscription is requested for an instrument_id that is not in the client's instrument cache and the config flag `auto_load_missing_instruments` is disabled. The client refuses to subscribe because it has no instrument definition for the requested feed.","triggerScenarios":"Calling subscribe_ticker_feed, subscribe_book_deltas, subscribe_book_depth10, or subscribe_trades with an InstrumentId that was never loaded into the cache while `auto_load_missing_instruments: false` in DeriveDataClientConfig.","commonSituations":"Explicitly disabling lazy instrument loading for determinism but requesting feeds for instruments not pre-loaded at startup; typos in instrument IDs (wrong venue or symbol case); subscribing before request_instruments completed.","solutions":["Set `auto_load_missing_instruments: true` in DeriveDataClientConfig so unknown instruments are fetched on demand.","Pre-load the instrument via request_instruments (with the right currencies configured) before subscribing.","Verify the InstrumentId matches a Derive-listed instrument exactly (symbol and venue)."],"exampleFix":"// before\nlet config = DeriveDataClientConfig { auto_load_missing_instruments: false, ..cfg };\n// after\nlet config = DeriveDataClientConfig { auto_load_missing_instruments: true, ..cfg };","handlingStrategy":"validation","validationCode":"// before subscribing\nlet known = client.instrument_cached(&instrument_id); // or track loaded ids\nassert!(known || cfg.auto_load_missing_instruments,\n    \"enable auto_load_missing_instruments or pre-load {instrument_id}\");","typeGuard":null,"tryCatchPattern":"match prepare_subscribe(instrument_id) {\n    Err(e) if e.to_string().contains(\"auto_load_missing_instruments\") => {\n        // enable lazy loading or fetch instrument first, then retry\n    }\n    r => r?,\n}","preventionTips":["Pre-load all instruments via request_instruments at startup.","Enable auto_load_missing_instruments unless determinism is required.","Validate instrument IDs against the exchange listing before subscribing."],"tags":["subscription","instrument-lookup","configuration","derive"],"backgroundTag":"resource-not-found","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"}