nautechsystems/nautilus_trader · error · anyhow::Error

Unsupported Data::Defi variant for catalog writes

Error message

Unsupported Data::Defi variant for catalog writes

What it means

`ParquetDataCatalog::write_data_enum` groups a buffer of `Data` enum values for writing, but DeFi data variants have no supported catalog write path, so the function aborts rather than silently dropping or mislabeling the data. Only standard and `Data::Custom` variants are writable via this method.

Source

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

                    index_prices.push(p);
                }
                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

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Filter `Data::Defi` variants out of the buffer before calling `write_data_enum`.
  2. Use the dedicated DeFi write path/API for those records instead of the generic enum writer.
  3. Split the buffer: write non-DeFi data via `write_data_enum` and handle DeFi data with its own writer or store it elsewhere.

Example fix

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

Strategy: validation

Validate before calling

assert!(!data.iter().any(|d| matches!(d, nautilus_model::data::Data::Defi(_))),
    "Defi data not supported by write_data_enum");

Type guard

fn is_defi(d: &nautilus_model::data::Data) -> bool {
    #[cfg(feature = "defi")]
    { matches!(d, nautilus_model::data::Data::Defi(_)) }
    #[cfg(not(feature = "defi"))]
    { false }
}

Try / catch

match catalog.write_data_enum(&data, None, None, None) {
    Err(e) if e.to_string().contains("Data::Defi") => route_to_defi_writer(&data)?,
    other => other?,
}

Prevention

When it happens

Trigger: Calling `write_data_enum` with a buffer containing at least one `Data::Defi` value (only compiled in with the `defi` feature enabled).

Common situations: Streaming DeFi (e.g. DEX pool/swap) data through the generic enum write path used for quotes/trades; Tardis CSV conversion pipelines that include DeFi records; scripts that replay mixed data into a catalog.

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