nautechsystems/nautilus_trader · error · anyhow::Error

Invalid `MarketStatusAction` value: {action}

Error message

Invalid `MarketStatusAction` value: {action}

What it means

decode_status_msg maps the raw u16 msg.action of a Databento status record to the domain MarketStatusAction enum. If the value has no mapping, the decode fails with this error rather than emitting an InstrumentStatus event.

Source

Thrown at crates/adapters/databento/src/decode/market_data.rs:759

    Ok(bar)
}

/// Decodes a Databento status message into an `InstrumentStatus` event.
///
/// # Errors
///
/// Returns an error if decoding the status message fails or if `msg.action` is not a valid `MarketStatusAction`.
pub fn decode_status_msg(
    msg: &dbn::StatusMsg,
    instrument_id: InstrumentId,
    ts_init: Option<UnixNanos>,
) -> anyhow::Result<InstrumentStatus> {
    let ts_event = msg.hd.ts_event.into();
    let ts_init = ts_init.unwrap_or(ts_event);

    let action = MarketStatusAction::from_u16(msg.action)
        .ok_or_else(|| anyhow::anyhow!("Invalid `MarketStatusAction` value: {}", msg.action))?;

    let status = InstrumentStatus::new(
        instrument_id,
        action,
        ts_event,
        ts_init,
        parse_status_reason(msg.reason)?,
        parse_status_trading_event(msg.trading_event)?,
        parse_optional_bool(msg.is_trading),
        parse_optional_bool(msg.is_quoting),
        parse_optional_bool(msg.is_short_sell_restricted),
    );

    Ok(status)
}

/// # Errors
///

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Upgrade nautilus-trader to a version whose MarketStatusAction covers the new action code
  2. Identify the failing action value and map it manually to a supported enum variant in a preprocessing step
  3. Skip unmapped status records instead of failing the whole load
  4. Check the dataset's status action codes against the enum's supported values

Example fix

// before
let status = decode_status_msg(&msg, instrument_id, None)?; // panics pipeline on new code
// after
match MarketStatusAction::from_u16(msg.action) {
    Some(_) => { let status = decode_status_msg(&msg, instrument_id, None)?; /* handle */ }
    None => log::warn("Skipping status action {}", msg.action),
}
Defensive patterns

Strategy: validation

Validate before calling

// Rust
let ok = MarketStatusAction::from_u16(msg.action).is_some();

Try / catch

// Rust
Err(e) => log::warn("skip: {e:#}"),

Prevention

When it happens

Trigger: Decoding a StatusMsg whose msg.action u16 is not covered by MarketStatusAction::from_u16 — e.g. a venue-specific or newly added status action code in a newer DBN schema or exchange dataset.

Common situations: Loading status records from datasets with extra market-status codes (halts, auctions, new action types); replaying data recorded with newer databento libraries than the adapter supports.

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