{"record":{"id":"75cd2617cd13e1dc","repo":"nautechsystems/nautilus_trader","slug":"failed-to-parse-any-of-input-len-lighter-instrum","errorCode":null,"errorMessage":"failed to parse any of {input_len} Lighter instruments: {}","messagePattern":"failed to parse any of (.+?) Lighter instruments: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/lighter/src/http/parse.rs","lineNumber":133,"sourceCode":"        }\n    }\n\n    for detail in spot_details {\n        match parse_spot_instrument(registry, detail, ts_init) {\n            Ok(instrument) => instruments.push((instrument, detail.order_book.status)),\n            Err(e) => {\n                log::warn!(\n                    \"Skipping invalid Lighter spot instrument `{}`: {e}\",\n                    detail.order_book.symbol,\n                );\n                first_error.get_or_insert_with(|| e.to_string());\n            }\n        }\n    }\n\n    let input_len = perp_details.len() + spot_details.len();\n    if input_len > 0 && instruments.is_empty() {\n        anyhow::bail!(\n            \"failed to parse any of {input_len} Lighter instruments: {}\",\n            first_error.as_deref().unwrap_or(\"unknown parse error\"),\n        );\n    }\n\n    Ok(instruments)\n}\n\n/// Parses a Lighter trade into a Nautilus [`TradeTick`].\n///\n/// # Errors\n///\n/// Returns an error if the price, size, timestamp, or trade id is invalid.\npub fn parse_trade_tick(\n    trade: &LighterTrade,\n    instrument: &InstrumentAny,\n    ts_init: UnixNanos,\n) -> anyhow::Result<TradeTick> {","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/lighter/src/http/parse.rs#L115-L151","documentation":"Raised by parse_order_book_details_instruments_with_status when the venue returned a non-empty set of order-book details (perps + spots) but zero of them could be parsed into instruments. The bail includes the total input count and the first parse error encountered, since every record failed and the first error is the most representative root cause.","triggerScenarios":"Calling get_order_book_details, request_instruments_with_status_for_query, or parse_order_book_details_instruments against a venue response whose records all fail parsing — e.g. an unexpected schema from an API change, new market type the parser does not handle, or corrupt/empty per-record fields.","commonSituations":"Lighter API schema changes (new fields/renames) breaking the parser, a venue response shape change after an adapter upgrade, or spot/perp detail records in an unexpected format.","solutions":["Inspect the embedded first_error to see why records failed to parse","Update the adapter/parser to match the current Lighter order-book-details API schema","Pin or verify the adapter version against the deployed venue API version","Log a sample raw response to diff against the parser's expectations"],"exampleFix":"// before: parse and assume success\nlet instruments = parse_order_book_details_instruments(&response)?;\n// after: fail loudly with a raw sample for diagnosis\nlet instruments = match parse_order_book_details_instruments(&response) {\n    Ok(i) if !i.is_empty() => i,\n    Ok(_) | Err(e) => {\n        log::error!(\"Lighter instruments parse failed: {e}; sample={:?}\", response.first());\n        return Err(e);\n    }\n};","handlingStrategy":"try-catch","validationCode":"// detect an empty/unexpected venue payload before parsing\nif perp_details.is_empty() && spot_details.is_empty() {\n    return Err(\"venue returned no order-book details\".into());\n}","typeGuard":null,"tryCatchPattern":"match parse_order_book_details_instruments(&response) {\n    Err(e) => {\n        let msg = e.to_string();\n        if msg.contains(\"failed to parse any of\") {\n            log::error!(\"Lighter schema drift suspected: {msg}; raw={:?}\", response.first());\n        }\n        Err(e)\n    }\n    ok => ok,\n}","preventionTips":["Log the raw venue response when instrument parsing fails to catch schema drift early","Pin adapter versions to tested venue API versions and diff on upgrade","Alert on zero-parsed-instrument results as a schema-change signal"],"tags":["parsing","instruments","api-schema","rust","venue"],"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-14T00:17:10.932Z"}