{"record":{"id":"0b2cc70f770dcf2c","repo":"nautechsystems/nautilus_trader","slug":"invalid-venue-code-exchange-e","errorCode":null,"errorMessage":"Invalid venue code '{exchange}': {e}","messagePattern":"Invalid venue code '(.+?)': (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/databento/src/live.rs","lineNumber":1080,"sourceCode":"    }\n\n    Ok(())\n}\n\n/// Updates the instrument ID map using exchange information from the symbol map.\nfn update_instrument_id_map_with_exchange(\n    symbol_map: &PitSymbolMap,\n    symbol_venue_map: &AtomicMap<Symbol, Venue>,\n    instrument_id_map: &mut AHashMap<u32, InstrumentId>,\n    raw_instrument_id: u32,\n    exchange: &str,\n) -> anyhow::Result<InstrumentId> {\n    let raw_symbol = symbol_map.get(raw_instrument_id).ok_or_else(|| {\n        anyhow::anyhow!(\"Cannot resolve raw_symbol for instrument_id {raw_instrument_id}\")\n    })?;\n    let symbol = Symbol::from(raw_symbol.as_str());\n    let venue = Venue::from_code(exchange)\n        .map_err(|e| anyhow::anyhow!(\"Invalid venue code '{exchange}': {e}\"))?;\n    let instrument_id = InstrumentId::new(symbol, venue);\n    symbol_venue_map.rcu(|m| {\n        m.entry(symbol).or_insert(venue);\n    });\n    instrument_id_map.insert(raw_instrument_id, instrument_id);\n    Ok(instrument_id)\n}\n\nfn update_instrument_id_map(\n    record: &dbn::RecordRef,\n    symbol_map: &PitSymbolMap,\n    publisher_venue_map: &IndexMap<PublisherId, Venue>,\n    symbol_venue_map: &AtomicMap<Symbol, Venue>,\n    instrument_id_map: &mut AHashMap<u32, InstrumentId>,\n) -> anyhow::Result<InstrumentId> {\n    let header = record.header();\n\n    // Check if instrument ID is already in the map","sourceCodeStart":1062,"sourceCodeEnd":1098,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/databento/src/live.rs#L1062-L1098","documentation":"The adapter builds a Venue from the Databento exchange string via `Venue::from_code`, which only accepts known/valid venue codes. The exchange string on the record did not map to a valid Nautilus Venue, so the instrument ID translation fails.","triggerScenarios":"`update_instrument_id_map_with_exchange` receives an `exchange` string from the symbol map/Databento record that `Venue::from_code` rejects — unknown code, empty string, or a code with invalid characters for a Venue.","commonSituations":"New or less-common Databento exchanges not present in the venue registry, exchange field empty on the record, `use_exchange_as_venue` enabled for datasets whose exchange labels don't match Nautilus venue codes.","solutions":["Disable `use_exchange_as_venue` so the adapter derives the venue from the Databento publisher ID instead of the raw exchange string","Check the exchange string in the error message against the supported venue code list; register or map unknown exchanges before use","Update to the latest nautilus version, which may have added the missing venue code","Sanitize/normalize the exchange string upstream (trim, uppercase) if it comes from custom configuration"],"exampleFix":"// before\nlet venue = Venue::from_code(exchange)\n    .map_err(|e| anyhow::anyhow!(\"Invalid venue code '{exchange}': {e}\"))?;\n// after: fall back to publisher-derived venue\nlet venue = Venue::from_code(exchange).unwrap_or_else(|_| {\n    log::warn!(\"Unknown exchange '{exchange}', falling back to publisher venue\");\n    publisher_venue_map[&publisher_id]\n});","handlingStrategy":"validation","validationCode":"// validate the exchange code before processing records\nlet known = [\"GLBX\", \"XNAS\", \"XNYS\", \"XCME\", \"EC4\"];\nassert!(known.contains(&exchange.to_uppercase().as_str()), \"unsupported exchange {exchange}\");","typeGuard":"fn is_valid_venue(code: &str) -> bool { Venue::from_code(code).is_ok() }","tryCatchPattern":"match Venue::from_code(exchange) {\n    Ok(v) => v,\n    Err(e) => return Err(anyhow::anyhow!(\"configure venue for '{exchange}': {e}\")),\n}","preventionTips":["Check exchange strings against supported venue codes before enabling use_exchange_as_venue","Keep the adapter updated for new exchange support","Prefer publisher-derived venues for datasets with non-standard exchange labels"],"tags":["databento","venue","invalid-argument","venue-code"],"backgroundTag":"invalid-enum-value","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"}