nautechsystems/nautilus_trader · error · anyhow::Error
Invalid value for `update_action`: {update_action}
Error message
Invalid value for `update_action`: {update_action} What it means
decode_statistics_msg converts a Databento statistics record into a DatabentoStatistics event. The record's update_action byte must map to a known DatabentoStatisticUpdateAction; any unmapped value aborts the decode with this anyhow error instead of producing an event.
Source
Thrown at crates/adapters/databento/src/decode/custom.rs:87
pub fn decode_statistics_msg(
msg: &dbn::StatMsg,
instrument_id: InstrumentId,
price_precision: u8,
ts_init: Option<UnixNanos>,
) -> anyhow::Result<Option<DatabentoStatistics>> {
let Some(stat_type) = u8::try_from(msg.stat_type)
.ok()
.and_then(DatabentoStatisticType::from_u8)
else {
log::warn!(
"Skipping unsupported `stat_type` {} for {instrument_id}",
msg.stat_type,
);
return Ok(None);
};
let update_action =
DatabentoStatisticUpdateAction::from_u8(msg.update_action).ok_or_else(|| {
anyhow::anyhow!("Invalid value for `update_action`: {}", msg.update_action)
})?;
let ts_event = msg.ts_recv.into();
let ts_init = ts_init.unwrap_or(ts_event);
Ok(Some(DatabentoStatistics::new(
instrument_id,
stat_type,
update_action,
decode_optional_price(msg.price, price_precision),
decode_optional_quantity(msg.quantity)?,
msg.channel_id,
msg.stat_flags,
msg.sequence,
msg.ts_ref.into(),
msg.ts_in_delta,
msg.hd.ts_event.into(),
ts_event,
ts_init,View on GitHub (pinned to 18893faf8b)
Solutions
- Upgrade nautilus-trader / the databento adapter to a version supporting the newer DBN schema
- Log and skip unknown update_action values instead of hard-failing (mirroring the unknown stat_type handling)
- Check the record's DBN version and the update_action value to confirm whether the schema is newer
- Report/patch DatabentoStatisticUpdateAction::from_u8 to map the new value
Example fix
// before
let update_action = DatabentoStatisticUpdateAction::from_u8(msg.update_action)
.ok_or_else(|| anyhow!("Invalid value for `update_action`: {}", msg.update_action))?;
// after
let Some(update_action) = DatabentoStatisticUpdateAction::from_u8(msg.update_action) else {
log::warn("Skipping statistics with unknown update_action {}", msg.update_action);
return Ok(None);
}; Defensive patterns
Strategy: validation
Validate before calling
// Rust let ok = DatabentoStatisticUpdateAction::from_u8(msg.update_action).is_some();
Try / catch
// Rust
Err(e) => log::warn("skip: {e:#}"), Prevention
- Align DBN versions
- Upgrade adapter
- Skip unknown values
- Pre-scan datasets
When it happens
Trigger: Feeding a Statistics record whose msg.update_action raw u8 is not recognized by DatabentoStatisticUpdateAction::from_u8 — typically a DBN schema revision introducing a new update action the decoder does not know.
Common situations: Replaying historical data recorded with a newer databento DBN version than the adapter supports; unexpected exchange-side statistics update actions in live streams; corrupted records.
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
- Invalid `TcbboMsg`: expected trade action, was {action}
- Invalid `MarketStatusAction` value: {action}
- Invalid `publisher` for record: {e}
- Invalid `{SCHEMA_PARAM}` '{schema}'. Must be one of: {allowe
- Invalid negative `contract_multiplier`: {value}
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/ae84822ef635584a.
Report an issue: GitHub.