nautechsystems/nautilus_trader · error · anyhow::Error

Unsupported Data variant for catalog writes

Error message

Unsupported Data variant for catalog writes

What it means

Catch-all arm in `ParquetDataCatalog::write_data_enum`: the `Data` enum contained a variant that is neither an instrument, order-book, quote, trade, nor `Data::Custom` type that the writer recognizes. The writer refuses instead of guessing how to serialize it.

Source

Thrown at crates/persistence/src/backend/catalog.rs:456

                Data::FundingRate(p) => {
                    funding_rates.push(p);
                }
                Data::OptionGreeks(g) => {
                    option_greeks.push(g);
                }
                Data::InstrumentStatus(s) => {
                    statuses.push(s);
                }
                Data::InstrumentClose(c) => {
                    closes.push(c);
                }
                Data::Custom(c) => {
                    custom_data.entry(custom_data_key(&c)).or_default().push(c);
                }
                #[cfg(feature = "defi")]
                Data::Defi(_) => anyhow::bail!("Unsupported Data::Defi variant for catalog writes"),
                #[allow(unreachable_patterns)]
                _ => anyhow::bail!("Unsupported Data variant for catalog writes"),
            }
        }

        // Instruments are handled separately via write_instruments method

        // Group each type by its identity so one write never mixes identifiers:
        // the target directory and schema metadata are taken from the first
        // element, so a mixed write would silently re-label the rest
        self.write_grouped_to_parquet(deltas, start, end, skip_disjoint_check, |d| {
            d.instrument_id
        })?;
        self.write_grouped_to_parquet(depth10s, start, end, skip_disjoint_check, |d| {
            d.instrument_id
        })?;
        self.write_grouped_to_parquet(quotes, start, end, skip_disjoint_check, |q| {
            q.instrument_id
        })?;
        self.write_grouped_to_parquet(trades, start, end, skip_disjoint_check, |t| {

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Identify the offending variant (log `data` or its type name before the write) and exclude it from the buffer.
  2. Confirm the persistence crate and nautilus_model versions are in sync (upgrade persistence if the model added variants).
  3. If it is a custom type, ensure it was registered via `#[custom_data]` so it matches `Data::Custom`.

Example fix

// before
catalog.write_data_enum(&data, None, None, None)?;
// after
let writable: Vec<Data> = data.into_iter()
    .filter(|d| !matches!(d, Data::Defi(_)))
    .collect();
catalog.write_data_enum(&writable, None, None, None)?;
Defensive patterns

Strategy: validation

Validate before calling

fn is_writable(d: &nautilus_model::data::Data) -> bool {
    !matches!(d, nautilus_model::data::Data::Other(_) | nautilus_model::data::Data::Defi(_))
}

Try / catch

if let Err(e) = catalog.write_data_enum(&data, None, None, None) {
    log::warn!("skipping unsupported data: {e}");
    // inspect and handle the offending variant manually
}

Prevention

When it happens

Trigger: Calling `write_data_enum` with a `Data` value whose inner type does not map to any supported Parquet-writable type, typically a newly added or unusual data variant not covered by the explicit match arms.

Common situations: Using a newer nautilus_model version whose `Data` enum gained variants the persistence crate does not yet handle; passing synthetically constructed `Data` values; forwarding custom types that do not implement the catalog custom-data contract.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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