{"record":{"id":"62eedbecf2156ebb","repo":"nautechsystems/nautilus_trader","slug":"on-symbol-mapping-failed-for-msg-e","errorCode":null,"errorMessage":"on_symbol_mapping failed for {msg:?}: {e}","messagePattern":"on_symbol_mapping failed for (.+?): (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/databento/src/live.rs","lineNumber":1029,"sourceCode":"        .strip_circumfix(\"Subscription request \", \" data succeeded\")\n        .and_then(|rest| rest.split_once(\" for \"))\n        .map(|(_, schema)| schema.trim().to_string())\n        .unwrap_or_default()\n}\n\n/// Handles symbol mapping messages and updates the instrument ID map.\n///\n/// # Errors\n///\n/// Returns an error if symbol mapping fails.\nfn handle_symbol_mapping_msg(\n    msg: &dbn::SymbolMappingMsg,\n    symbol_map: &mut PitSymbolMap,\n    instrument_id_map: &mut AHashMap<u32, InstrumentId>,\n) -> anyhow::Result<()> {\n    symbol_map\n        .on_symbol_mapping(msg)\n        .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}\"))?;","sourceCodeStart":1011,"sourceCodeEnd":1047,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/databento/src/live.rs#L1011-L1047","documentation":"When the live feed delivers a `dbn::SymbolMappingMsg`, the feed handler applies it to a point-in-time `PitSymbolMap` via `on_symbol_mapping`. If that mapping update fails, the error is wrapped with the offending message and this text. A failure here means symbol-mapping state (Databento raw symbol to instrument ID) can no longer be trusted for that channel, so decoding subsequent records for that instrument may be wrong.","triggerScenarios":"A symbol mapping record arrives whose content the `PitSymbolMap` rejects — e.g. a mapping inconsistent with previously seen mappings, malformed mapping data in the Databento stream, or a pit-map invariant violation while processing the `SymbolMappingMsg`.","commonSituations":"Databento schema/symbology changes producing unexpected mapping records; subscribing with stype combinations that yield conflicting mappings; corrupted or out-of-order stream data after reconnects; version drift between the databento crate and server record formats.","solutions":["Inspect the logged `msg` to see the exact SymbolMappingMsg that was rejected","Check the databento crate version matches the server dataset/schema expectations (upgrade if needed)","Verify the stype_in/stype_out combination used at subscribe time is consistent","Clear/reset the symbol map state (restart the session) so the PitSymbolMap is rebuilt cleanly","If persistent, report/reproduce with Databento support — the mapping record may be genuinely malformed"],"exampleFix":"// before\nsymbol_map.on_symbol_mapping(msg)?;\n\n// after\nsymbol_map\n    .on_symbol_mapping(msg)\n    .map_err(|e| {\n        log::warn!(\"skipping bad symbol mapping: {e}\");\n        anyhow::anyhow!(\"on_symbol_mapping failed for {msg:?}: {e}\")\n    })?;","handlingStrategy":"try-catch","validationCode":"// pin and verify databento crate version against dataset expectations\ncargo tree -p databento | grep databento","typeGuard":null,"tryCatchPattern":"match feed_result {\n    Err(e) if e.to_string().contains(\"on_symbol_mapping failed\") => {\n        log::error!(\"symbol mapping failure: {e:#}\");\n        // rebuild symbol map / restart session with consistent stype\n    }\n    other => other?,\n}","preventionTips":["Keep the databento crate up to date and matched across services","Use a single consistent stype_in/stype_out for all subscriptions in a session","Log SymbolMappingMsg contents at debug level to diagnose rejects quickly","Restart sessions cleanly on mapping errors so PitSymbolMap state is rebuilt"],"tags":["rust","databento","live-streaming","symbol-mapping","protocol"],"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"}