{"record":{"id":"f09449a7fe704a07","repo":"nautechsystems/nautilus_trader","slug":"failed-to-parse-matching-lighter-order-for-mark","errorCode":null,"errorMessage":"failed to parse matching Lighter order {} for market_index={market_index}","messagePattern":"failed to parse matching Lighter order (.+?) for market_index=(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/lighter/src/websocket/dispatch.rs","lineNumber":1851,"sourceCode":"    let auth = mint_auth_token(credential)?;\n    let query = Zeroizing::new(LighterAccountActiveOrdersQuery {\n        authorization: None,\n        auth: Some(auth.clone()),\n        account_index: credential.account_index(),\n        market_id: market_index,\n    });\n    let active = http_client\n        .get_account_active_orders(&query)\n        .await\n        .context(\"failed to fetch Lighter active orders\")?;\n\n    let ts_init = clock.get_time_ns();\n    let supplied_cloid = client_order_id.copied();\n\n    let finalize = |order: &LighterOrder| -> anyhow::Result<OrderStatusReport> {\n        let report =\n            parse_http_order_to_report(order, registry, account_id, ts_init).ok_or_else(|| {\n                anyhow::anyhow!(\n                    \"failed to parse matching Lighter order {} for market_index={market_index}\",\n                    order.order_id,\n                )\n            })?;\n        let mut report = dispatch.translate_order_cloid(report);\n        // Substitute the caller-supplied cloid whenever it positively\n        // identifies this order: when the order's\n        // `client_order_index` equals the deterministic derivation from\n        // `supplied_cloid`. This covers two cases the cloid_map cannot\n        // serve after a fresh client instance:\n        //   1. The match came via `client_order_index`.\n        //   2. The match came via venue order id, but the caller also\n        //      supplied the matching cloid.\n        // Substituting on the derivation match (rather than which path\n        // matched first) avoids leaving the venue numeric cloid on the\n        // report whenever the supplied cloid is the right one.\n        if let Some(cloid) = supplied_cloid\n            && let Some(client_index) = target_client_index","sourceCodeStart":1833,"sourceCodeEnd":1869,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/lighter/src/websocket/dispatch.rs#L1833-L1869","documentation":"A venue order matching the lookup criteria was found, but parse_http_order_to_report could not convert it into an OrderStatusReport (instrument mapping or field validation failed). The lookup aborts instead of returning a malformed report.","triggerScenarios":"finalize() called on a matched LighterOrder whose market/instrument mapping or numeric fields fail parsing — e.g. matching order belongs to a market absent from the registry, or contains values the parser rejects.","commonSituations":"Reconciling orders on markets outside the configured instrument set; venue-side field changes (new order states/pricing) not yet handled by the parser; corrupted or partial order payloads.","solutions":["Confirm the matched order's market has a registered instrument before querying (load/refresh instruments).","Capture the raw order payload in logs and update parse_http_order_to_report to accept the new shape.","Restrict the query to markets in your configured instrument universe."],"exampleFix":"// before: query against a market not in the registry\nlet report = lookup(..., market_index_not_loaded)?;\n// after: guard first\nanyhow::ensure!(registry.instrument_for_market(market_index).is_some(), \"market {market_index} not registered\");","handlingStrategy":"try-catch","validationCode":"if registry.instrument_for_market(market_index).is_none() { skip; }","typeGuard":null,"tryCatchPattern":"match lookup { Err(e) if e.to_string().contains(\"failed to parse matching Lighter order\") => { /* refresh instruments, log raw order, retry */ }, r => r? }","preventionTips":["Keep the instrument registry in sync with queried markets","Handle new venue order fields in the parser promptly","Log raw matched orders when parse fails"],"tags":["parsing","reconciliation","instrument-registry"],"backgroundTag":"unexpected-api-response-shape","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"}