{"record":{"id":"3e201e208babdedc","repo":"nautechsystems/nautilus_trader","slug":"missing-exchange-for-record-e","errorCode":null,"errorMessage":"Missing `exchange` for record: {e}","messagePattern":"Missing `exchange` for record: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/databento/src/loader.rs","lineNumber":282,"sourceCode":"                let result: anyhow::Result<Option<InstrumentAny>> = (|| {\n                    let record = dbn::RecordRef::from(rec);\n                    let msg = record\n                        .get::<InstrumentDefMsg>()\n                        .ok_or_else(|| anyhow::anyhow!(\"Failed to decode InstrumentDefMsg\"))?;\n\n                    let raw_symbol = rec\n                        .raw_symbol()\n                        .map_err(|e| anyhow::anyhow!(\"Error decoding `raw_symbol`: {e}\"))?;\n                    let symbol = Symbol::from(raw_symbol);\n\n                    let publisher = rec\n                        .hd\n                        .publisher()\n                        .map_err(|e| anyhow::anyhow!(\"Invalid `publisher` for record: {e}\"))?;\n                    let venue = match publisher {\n                        Publisher::GlbxMdp3Glbx if use_exchange_as_venue => {\n                            let exchange = rec.exchange().map_err(|e| {\n                                anyhow::anyhow!(\"Missing `exchange` for record: {e}\")\n                            })?;\n                            let venue = Venue::from_code(exchange).map_err(|e| {\n                                anyhow::anyhow!(\"Venue not found for exchange {exchange}: {e}\")\n                            })?;\n                            self.symbol_venue_map.insert(symbol, venue);\n                            venue\n                        }\n                        _ => *self\n                            .publisher_venue_map\n                            .get(&msg.hd.publisher_id)\n                            .ok_or_else(|| {\n                                anyhow::anyhow!(\n                                    \"Venue not found for publisher_id {}\",\n                                    msg.hd.publisher_id\n                                )\n                            })?,\n                    };\n                    let instrument_id = InstrumentId::new(symbol, venue);","sourceCodeStart":264,"sourceCodeEnd":300,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/databento/src/loader.rs#L264-L300","documentation":"For GLBX.MDP3 publisher records when `use_exchange_as_venue` is enabled, the loader calls `rec.exchange()` to derive the venue from the record's exchange code. If the record carries no exchange field the map_err wraps the failure as this error.","triggerScenarios":"Reading definition records with `use_exchange_as_venue = true` where a GLBX.MDP3 record lacks the exchange field (e.g. certain instrument definition schemas or record types that omit exchange).","commonSituations":"Loading older GLBX definition datasets where exchange was not populated, or feeding non-GLBX records mislabeled with the GlbxMdp3Glbx publisher.","solutions":["Set `use_exchange_as_venue = false` so the venue comes from the publisher map instead of the exchange field","Verify the dataset/record type actually carries an exchange field (check schema version)","Update the `dbn` crate and re-export the data, since newer schemas populate exchange consistently","Filter out records with empty exchange before feeding the loader"],"exampleFix":"// before\nlet loader = DatabentoInstrumentLoader::new(publisher_venue_map, true);\n// after\nlet loader = DatabentoInstrumentLoader::new(publisher_venue_map, false); // fall back to publisher_id venue mapping","handlingStrategy":"validation","validationCode":"// only use exchange-as-venue for GLBX data whose records carry exchange codes\nlet use_exchange_as_venue = dataset == \"GLBX.L3\" && schema_supports_exchange(schema);","typeGuard":null,"tryCatchPattern":"match loader.load_instruments(file) {\n    Ok(i) => i,\n    Err(e) if e.to_string().contains(\"Missing `exchange`\") => {\n        // retry with publisher-based venue mapping\n        DatabentoInstrumentLoader::new(publisher_venue_map, false).load_instruments(file)\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Enable `use_exchange_as_venue` only for GLBX.MDP3 datasets","Confirm the schema version populates the exchange field","Prefer publisher-based venue mapping unless per-exchange venues are required"],"tags":["databento","dbn-decoding","missing-field"],"backgroundTag":"empty-required-field","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"}