{"record":{"id":"9d504b1ec30ec747","repo":"nautechsystems/nautilus_trader","slug":"lighter-fill-instrument-instrument-id-missing-fr","errorCode":null,"errorMessage":"Lighter fill instrument {instrument_id} missing from cache","messagePattern":"Lighter fill instrument (.+?) missing from cache","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/lighter/src/execution.rs","lineNumber":5286,"sourceCode":"                        \"Lighter get_trades failed (market_id={:?}, account_index={}, cursor={:?}): {}\",\n                        query.market_id,\n                        credential.account_index(),\n                        cursor,\n                        scrub_auth(&format!(\"{e:#}\")),\n                    );\n                    return Err(anyhow::Error::new(e).context(\"failed to fetch Lighter fills\"));\n                }\n            };\n\n            for trade in &response.trades {\n                let Some(instrument_id) = self.registry.instrument_id(trade.market_id) else {\n                    anyhow::bail!(\n                        \"no Lighter instrument registered for fill market_index={}\",\n                        trade.market_id,\n                    );\n                };\n                let Some(instrument) = self.core.cache().instrument(&instrument_id).cloned() else {\n                    anyhow::bail!(\"Lighter fill instrument {instrument_id} missing from cache\");\n                };\n\n                match parse_ws_fill_report(\n                    trade,\n                    credential.account_index(),\n                    &instrument,\n                    self.core.account_id,\n                    ts_init,\n                ) {\n                    Ok(Some(report)) => {\n                        if cmd.start.is_some_and(|start| report.ts_event < start)\n                            || cmd.end.is_some_and(|end| report.ts_event > end)\n                        {\n                            continue;\n                        }\n\n                        // Mass-status reconciliation must surface the original\n                        // Nautilus cloid, not the venue's numeric echo.","sourceCodeStart":5268,"sourceCodeEnd":5304,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/lighter/src/execution.rs#L5268-L5304","documentation":"The fill's market_id mapped to a registered instrument_id, but the corresponding Instrument definition is missing from the core cache. The registry knows the venue market, yet the cache layer (populated by instrument loading/subscription) does not hold the instrument needed to parse the fill into a report.","triggerScenarios":"Processing a fetched fill whose instrument was registered in the adapter registry but never added to (or evicted from) the core cache — partial startup, cache cleared mid-session, or a race between fills fetching and cache population.","commonSituations":"Fills fetching racing instrument cache warm-up at startup, a cache invalidation/reset during the session, or instrument load errors that left the registry and cache inconsistent.","solutions":["Ensure instruments are loaded into the cache before enabling fills fetching","Reload instruments into the cache (re-run instrument initialization)","Retry the fills fetch after cache warm-up completes","Report/fix the registry-vs-cache inconsistency if it persists across restarts"],"exampleFix":"// before: start fills polling immediately\nclient.spawn_fills_poller();\n// after: wait until cache has the instruments\nclient.load_instruments_to_cache().await;\nclient.spawn_fills_poller();","handlingStrategy":"validation","validationCode":"// ensure the cache is warm before fills processing\nfor id in client.registry.instrument_ids() {\n    assert!(client.core.cache().instrument(&id).is_some(), \"cache missing {id}\");\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = client.fetch_fills().await {\n    if e.to_string().contains(\"missing from cache\") {\n        client.load_instruments_to_cache().await;\n        client.fetch_fills().await?;\n    } else { return Err(e); }\n}","preventionTips":["Warm the instrument cache before starting fills fetching","Reload the cache after any cache reset/invalidation event","Keep registry and cache population in a single initialization step so they cannot diverge"],"tags":["cache","fills","rust","instrument","inconsistent-state"],"backgroundTag":"entity-not-found","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}