nautechsystems/nautilus_trader · error

Invalid `publisher` for record: {e}

Error message

Invalid `publisher` for record: {e}

What it means

When decoding Databento DBN definition records in `read_definition_records`, the record header's publisher cannot be resolved (`rec.hd.publisher()` returned an Err). The loader needs the publisher to map each definition to a Nautilus `Venue`; if the header publisher field is invalid or unreadable it aborts with this anyhow error.

Source

Thrown at crates/adapters/databento/src/loader.rs:278

                }

                let rec = dbn_stream.get()?;

                let result: anyhow::Result<Option<InstrumentAny>> = (|| {
                    let record = dbn::RecordRef::from(rec);
                    let msg = record
                        .get::<InstrumentDefMsg>()
                        .ok_or_else(|| anyhow::anyhow!("Failed to decode InstrumentDefMsg"))?;

                    let raw_symbol = rec
                        .raw_symbol()
                        .map_err(|e| anyhow::anyhow!("Error decoding `raw_symbol`: {e}"))?;
                    let symbol = Symbol::from(raw_symbol);

                    let publisher = rec
                        .hd
                        .publisher()
                        .map_err(|e| anyhow::anyhow!("Invalid `publisher` for record: {e}"))?;
                    let venue = match publisher {
                        Publisher::GlbxMdp3Glbx if use_exchange_as_venue => {
                            let exchange = rec.exchange().map_err(|e| {
                                anyhow::anyhow!("Missing `exchange` for record: {e}")
                            })?;
                            let venue = Venue::from_code(exchange).map_err(|e| {
                                anyhow::anyhow!("Venue not found for exchange {exchange}: {e}")
                            })?;
                            self.symbol_venue_map.insert(symbol, venue);
                            venue
                        }
                        _ => *self
                            .publisher_venue_map
                            .get(&msg.hd.publisher_id)
                            .ok_or_else(|| {
                                anyhow::anyhow!(
                                    "Venue not found for publisher_id {}",
                                    msg.hd.publisher_id

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Check the publisher_id field of the offending record with `databento` CLI or `dbn` inspect tooling to confirm it is valid
  2. Update the `databento-dbn` crate to the latest version so new publisher schemas are recognized
  3. Re-download the dataset from Databento so the definitions file is not truncated or corrupt
  4. If the file was assembled manually, ensure each record's hd.publisher_id matches a valid Databento publisher

Example fix

// before
let publisher = rec.hd.publisher().map_err(|e| anyhow::anyhow!("Invalid `publisher` for record: {e}"))?;
// after
let publisher = rec.hd.publisher().map_err(|e| anyhow::anyhow!("Invalid `publisher` {} for record with raw_symbol {}: {e}", rec.hd.publisher_id, rec.raw_symbol()))?;
Defensive patterns

Strategy: validation

Validate before calling

// before loading, sanity-check the first record header
let rec = dbn_stream.get().expect("stream has records");
assert!(rec.hd.publisher_id != 0, "publisher_id must be set");
assert!(rec.hd.publisher().is_ok(), "publisher header must resolve");

Try / catch

match loader.load_instruments(file) {
    Ok(instruments) => instruments,
    Err(e) if e.to_string().contains("Invalid `publisher`") => {
        log::error!("corrupt/unrecognized DBN publisher header: {e}; re-download the file");
        Vec::new()
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Calling `load_instruments` (via `read_definition_records`) on a DBN stream/file whose definition records have a corrupt, zeroed, or unrecognized publisher_id in the record header.

Common situations: Manually concatenated DBN files, records produced by a newer databento schema version whose header layout the installed `dbn` crate cannot parse, or truncated/corrupt downloads.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/3b24ac6c7609b6e8. Report an issue: GitHub.