nautechsystems/nautilus_trader · error

Invalid `StatusMsg` trading_event, was '{value}'

Error message

Invalid `StatusMsg` trading_event, was '{value}'

What it means

`parse_status_trading_event` maps Databento status trading-event codes (0 none, 1 no cancel, 2 change trading session, 3/4 implied matching on/off) to strings. Code 0 means 'no event' and returns Ok(None); any other unmapped code bails with this message.

Source

Thrown at crates/adapters/databento/src/decode/primitives.rs:216

        invalid => anyhow::bail!("Invalid `StatusMsg` reason, was '{invalid}'"),
    };

    Ok(Some(Ustr::from(value_str)))
}

/// Parses a Databento status trading event code into a human-readable string.
///
/// # Errors
///
/// Returns an error if `value` is an invalid status trading event code.
pub fn parse_status_trading_event(value: u16) -> anyhow::Result<Option<Ustr>> {
    let value_str = match value {
        0 => return Ok(None),
        1 => "No cancel",
        2 => "Change trading session",
        3 => "Implied matching on",
        4 => "Implied matching off",
        _ => anyhow::bail!("Invalid `StatusMsg` trading_event, was '{value}'"),
    };

    Ok(Some(Ustr::from(value_str)))
}

/// Decodes a price, returning an error if undefined.
///
/// Databento uses `i64::MAX` as a sentinel value for unset/null prices (see
/// [`UNDEF_PRICE`](https://docs.rs/dbn/latest/dbn/constant.UNDEF_PRICE.html)).
///
/// # Errors
///
/// Returns an error if `value` is `i64::MAX` (undefined).
#[inline(always)]
pub fn decode_price(value: i64, precision: u8, field_name: &str) -> anyhow::Result<Price> {
    if value == i64::MAX {
        anyhow::bail!("Missing required price for `{field_name}`")
    } else {

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Upgrade the adapter crate so the trading-event table includes new codes
  2. Look up the numeric code in Databento's status documentation
  3. Skip or log-and-continue on such status records until supported
  4. Report the unmapped code upstream
Defensive patterns

Strategy: try-catch

Validate before calling

fn is_known_trading_event(v: u8) -> bool { matches!(v, 0..=4) } // verify against current adapter table

Try / catch

match decode_status_msg(msg) {
    Ok(s) => s,
    Err(e) if e.to_string().contains("Invalid `StatusMsg` trading_event") => {
        log::warn!("unknown trading_event code; skipping status record");
        None
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Decoding a `StatusMsg` whose `trading_event` field is a code outside {0,1,2,3,4}, typically via `decode_status_msg` while processing instrument status records.

Common situations: New trading-event codes introduced by Databento or an exchange; version skew between the dbn crate and the adapter's mapping table; unexpected status records from less common datasets.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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