nautechsystems/nautilus_trader · error

Invalid `StatusMsg`

Error message

Invalid `StatusMsg`

What it means

`load_status_records` expects every record in the stream to decode as `dbn::StatusMsg`. If `record.get::<StatusMsg>()` returns None (record is of another type), the loader returns this error. It guards against schema/rtype mismatches when loading instrument status data.

Source

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

            if let Err(e) = dbn_stream.advance() {
                return Some(Err(e.into()));
            }

            match dbn_stream.get() {
                Some(rec) => {
                    let record = dbn::RecordRef::from(rec);
                    let instrument_id = match self.resolve_record_instrument_id(
                        &record,
                        instrument_id,
                        &mut metadata_cache,
                    ) {
                        Ok(id) => id,
                        Err(e) => return Some(Err(e)),
                    };

                    let msg = match record.get::<dbn::StatusMsg>() {
                        Some(m) => m,
                        None => return Some(Err(anyhow::anyhow!("Invalid `StatusMsg`"))),
                    };
                    let ts_init = msg.ts_recv.into();

                    match decode_status_msg(msg, instrument_id, Some(ts_init)) {
                        Ok(data) => Some(Ok(data)),
                        Err(e) => Some(Err(e)),
                    }
                }
                None => None,
            }
        }))
    }

    /// Reads imbalance messages from a DBN IMBALANCE schema file.
    ///
    /// # Errors
    ///
    /// Returns an error if reading imbalance records fails.

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Download with `schema="status"` so the stream contains only StatusMsg records
  2. Check that the file passed to `load_status_records` is the status export, not trades/quotes
  3. Avoid concatenating DBN files of different schemas; process each separately
  4. Inspect the stream's rtype with dbn tooling to confirm it is `instrument_status`
Defensive patterns

Strategy: validation

Validate before calling

assert_eq!(request.schema, "status", "load_status_records requires the status schema");

Type guard

fn is_status_record(rec: &dbn::RecordRef) -> bool {
    rec.get::<dbn::StatusMsg>().is_some()
}

Try / catch

match loader.load_status_records(file, instrument_id) {
    Ok(d) => d,
    Err(e) if e.to_string().contains("Invalid `StatusMsg`") => {
        anyhow::bail!("file does not contain status records; check the schema used at download");
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Calling `load_status_records` on a DBN file/stream whose records are not status records (wrong schema downloaded, or mixed-record stream where a non-status record appears).

Common situations: Downloading `status` schema data but saving/exporting with a different schema, or concatenating multiple schema files into one input.

Understand the failure class

Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.

Related errors


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