{"record":{"id":"2c132a009050132b","repo":"nautechsystems/nautilus_trader","slug":"error-decoding-stype-in-symbol-e","errorCode":null,"errorMessage":"Error decoding `stype_in_symbol`: {e}","messagePattern":"Error decoding `stype_in_symbol`: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/databento/src/live.rs","lineNumber":1047,"sourceCode":"        .map_err(|e| anyhow::anyhow!(\"on_symbol_mapping failed for {msg:?}: {e}\"))?;\n    instrument_id_map.remove(&msg.header().instrument_id);\n    Ok(())\n}\n\nfn update_price_precision_map_with_symbol_mapping_msg(\n    msg: &dbn::SymbolMappingMsg,\n    price_precision_overrides: &AHashMap<Symbol, u8>,\n    subscription_price_precision_map: &mut AHashMap<u32, u8>,\n) -> anyhow::Result<()> {\n    subscription_price_precision_map.remove(&msg.hd.instrument_id);\n\n    if price_precision_overrides.is_empty() {\n        return Ok(());\n    }\n\n    let stype_in_symbol = msg\n        .stype_in_symbol()\n        .map_err(|e| anyhow::anyhow!(\"Error decoding `stype_in_symbol`: {e}\"))?;\n    let stype_out_symbol = msg\n        .stype_out_symbol()\n        .map_err(|e| anyhow::anyhow!(\"Error decoding `stype_out_symbol`: {e}\"))?;\n\n    let price_precision = [stype_in_symbol, stype_out_symbol]\n        .into_iter()\n        .find_map(|symbol| {\n            price_precision_overrides\n                .get(&Symbol::from_str_unchecked(symbol))\n                .copied()\n        });\n\n    if let Some(price_precision) = price_precision {\n        subscription_price_precision_map.insert(msg.hd.instrument_id, price_precision);\n    }\n\n    Ok(())\n}","sourceCodeStart":1029,"sourceCodeEnd":1065,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/databento/src/live.rs#L1029-L1065","documentation":"Raised while processing a Databento SymbolMappingMsg when the adapter cannot UTF-8-decode the `stype_in` symbol field from the record. Databento stores symbols as fixed byte arrays with a length byte; a corrupt, truncated, or invalid-length field makes `stype_in_symbol()` return a decode error, which the adapter propagates as anyhow error while updating the price precision map.","triggerScenarios":"A live Databento session (run_session) receives a SymbolMappingMsg while `price_precision_overrides` is non-empty, and the record's stype_in symbol bytes cannot be decoded (invalid UTF-8 or bad length prefix in the DBN record).","commonSituations":"Corrupted DBN stream data from the live gateway, decoding with a mismatched dbn crate version that interprets the record layout differently, or replaying a truncated/partially written recording.","solutions":["Upgrade the `databento-dbn` crate in both the adapter and any user code to matching, current versions so record decoding agrees","Re-establish the live session; if reproducible, capture the raw stream and report the malformed SymbolMappingMsg to Databento support","If precision overrides are not actually needed for that subscription, pass an empty `price_precision_overrides` so symbol mapping messages skip decoding entirely","Log and skip the failing record instead of failing the session by handling the error in the run_session record loop"],"exampleFix":"// before\nlet stype_in_symbol = msg\n    .stype_in_symbol()\n    .map_err(|e| anyhow::anyhow!(\"Error decoding `stype_in_symbol`: {e}\"))?;\n// after: tolerate a single bad record without killing the session\nlet stype_in_symbol = match msg.stype_in_symbol() {\n    Ok(s) => s,\n    Err(e) => {\n        log::warn!(\"Skipping symbol mapping msg: {e}\");\n        return Ok(());\n    }\n};","handlingStrategy":"try-catch","validationCode":"// ensure overrides exist only if symbols are well-formed UTF-8\nif !price_precision_overrides.is_empty() {\n    // decoding only happens when overrides are non-empty\n}","typeGuard":"fn has_overrides(overrides: &AHashMap<Symbol, u8>) -> bool { !overrides.is_empty() }","tryCatchPattern":"match result {\n    Ok(()) => {},\n    Err(e) if e.to_string().contains(\"stype_in_symbol\") => log::warn!(\"bad symbol mapping record: {e}\"),\n    Err(e) => return Err(e),\n}","preventionTips":["Keep the databento-dbn dependency version current and consistent","Only populate price_precision_overrides for symbols you actually need","Reconnect on repeated decode failures to rule out transient stream corruption"],"tags":["databento","decoding","live-stream","utf-8"],"backgroundTag":"json-decode-failed","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"}