nautechsystems/nautilus_trader · error

Venue not found for publisher_id {}

Error message

Venue not found for publisher_id {}

What it means

When the publisher is not GLBX.MDP3 (or exchange-as-venue is disabled), the venue is looked up in the loader's `publisher_venue_map` by `msg.hd.publisher_id`. A missing entry means the caller did not configure a venue for that Databento publisher.

Source

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

                        .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
                                )
                            })?,
                    };
                    let instrument_id = InstrumentId::new(symbol, venue);
                    let ts_init = msg.ts_recv.into();

                    decode_instrument_def_msg(rec, instrument_id, Some(ts_init), decode_config)
                })();

                match result {
                    Ok(Some(item)) => return Some(Ok(item)),
                    Ok(None) => {}
                    Err(e) => return Some(Err(e)),
                }
            }
        }))

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Add the missing publisher-to-venue entry to `publisher_venue_map` when constructing `DatabentoInstrumentLoader`
  2. Check `msg.hd.publisher_id` in the error message and map that exact publisher (e.g. `Publisher::Xnas::..., Venue::NASDAQ`)
  3. Use the standard `get_publisher_venue_map`/default mappings from the adapter rather than a hand-built map
  4. Upgrade the adapter if the publisher is a newly added Databento publisher

Example fix

// before
let loader = DatabentoInstrumentLoader::new(
    HashMap::from([(Publisher::GlbxMdp3Glbx, Venue::from_code("GLBX"))]),
    true,
);
// after
let loader = DatabentoInstrumentLoader::new(
    HashMap::from([
        (Publisher::GlbxMdp3Glbx, Venue::from_code("GLBX")),
        (Publisher::Opra, Venue::from_code("OPRA")),
    ]),
    true,
);
Defensive patterns

Strategy: validation

Validate before calling

// ensure every publisher in the dataset has a venue mapping before loading
for pub_id in expected_publishers {
    assert!(publisher_venue_map.contains_key(&pub_id), "no venue for {pub_id:?}");
}

Try / catch

match loader.load_instruments(file) {
    Ok(i) => i,
    Err(e) if e.to_string().contains("Venue not found for publisher_id") => {
        let id: u16 = /* parse from message */ 0;
        let publisher = Publisher::try_from(id)?;
        anyhow::bail!("add a venue mapping for publisher {publisher:?} to publisher_venue_map");
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Calling `read_definition_records`/`load_instruments` with a `publisher_venue_map` that lacks an entry for the publisher_id present in the records (e.g. OPRA, XNAS, EQUS publishers not mapped).

Common situations: Loading non-futures datasets (equities, options) while only configuring the default GLBX mapping; typos in publisher enum used to build the map.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


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