nautechsystems/nautilus_trader · error

Invalid `StatusMsg` reason, was '{invalid}'

Error message

Invalid `StatusMsg` reason, was '{invalid}'

What it means

`parse_status_reason` maps Databento status reason codes (e.g. 120-124 market-wide halts, 130 quotation not available) to human-readable strings. A reason code outside the mapped table has no known meaning, so the parser bails rather than emitting a wrong label.

Source

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

        30 => "News pending",
        31 => "News released",
        32 => "News and resumption times",
        33 => "News not forthcoming",
        40 => "Order imbalance",
        50 => "LULD pause",
        60 => "Operational",
        70 => "Additional information requested",
        80 => "Merger effective",
        90 => "ETF",
        100 => "Corporate action",
        110 => "New Security offering",
        120 => "Market wide halt level 1",
        121 => "Market wide halt level 2",
        122 => "Market wide halt level 3",
        123 => "Market wide halt carryover",
        124 => "Market wide halt resumption",
        130 => "Quotation not available",
        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}'"),

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Upgrade the adapter crate to get the latest reason-code table
  2. Check the Databento status code documentation for the numeric value
  3. If the code is legitimately new, filter or pass through status records without reason decoding until support lands
  4. Report the unmapped code to adapter maintainers
Defensive patterns

Strategy: try-catch

Try / catch

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

Prevention

When it happens

Trigger: Decoding a `StatusMsg` whose `reason` code is not in the lookup table (codes like 1..130 that the adapter maps, or new codes Databento introduced).

Common situations: Exchange adding new halt reasons; newer dbn crate producing codes the adapter table predates; receiving status records from datasets/exchanges with unmapped codes.

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/eac5cf8bf84e6eeb. Report an issue: GitHub.