{"record":{"id":"efc07e888c774084","repo":"nautechsystems/nautilus_trader","slug":"unsupported-data-defi-variant-for-catalog-writes","errorCode":null,"errorMessage":"Unsupported Data::Defi variant for catalog writes","messagePattern":"Unsupported Data::Defi variant for catalog writes","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/persistence/src/backend/catalog.rs","lineNumber":454,"sourceCode":"                    index_prices.push(p);\n                }\n                Data::FundingRate(p) => {\n                    funding_rates.push(p);\n                }\n                Data::OptionGreeks(g) => {\n                    option_greeks.push(g);\n                }\n                Data::InstrumentStatus(s) => {\n                    statuses.push(s);\n                }\n                Data::InstrumentClose(c) => {\n                    closes.push(c);\n                }\n                Data::Custom(c) => {\n                    custom_data.entry(custom_data_key(&c)).or_default().push(c);\n                }\n                #[cfg(feature = \"defi\")]\n                Data::Defi(_) => anyhow::bail!(\"Unsupported Data::Defi variant for catalog writes\"),\n                #[allow(unreachable_patterns)]\n                _ => anyhow::bail!(\"Unsupported Data variant for catalog writes\"),\n            }\n        }\n\n        // Instruments are handled separately via write_instruments method\n\n        // Group each type by its identity so one write never mixes identifiers:\n        // the target directory and schema metadata are taken from the first\n        // element, so a mixed write would silently re-label the rest\n        self.write_grouped_to_parquet(deltas, start, end, skip_disjoint_check, |d| {\n            d.instrument_id\n        })?;\n        self.write_grouped_to_parquet(depth10s, start, end, skip_disjoint_check, |d| {\n            d.instrument_id\n        })?;\n        self.write_grouped_to_parquet(quotes, start, end, skip_disjoint_check, |q| {\n            q.instrument_id","sourceCodeStart":436,"sourceCodeEnd":472,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/persistence/src/backend/catalog.rs#L436-L472","documentation":"`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.","triggerScenarios":"Calling `write_data_enum` with a buffer containing at least one `Data::Defi` value (only compiled in with the `defi` feature enabled).","commonSituations":"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.","solutions":["Filter `Data::Defi` variants out of the buffer before calling `write_data_enum`.","Use the dedicated DeFi write path/API for those records instead of the generic enum writer.","Split the buffer: write non-DeFi data via `write_data_enum` and handle DeFi data with its own writer or store it elsewhere."],"exampleFix":"// before\ncatalog.write_data_enum(&data, None, None, None)?;\n// after\nlet supported: Vec<Data> = data.into_iter().filter(|d| !matches!(d, Data::Defi(_))).collect();\ncatalog.write_data_enum(&supported, None, None, None)?;","handlingStrategy":"validation","validationCode":"assert!(!data.iter().any(|d| matches!(d, nautilus_model::data::Data::Defi(_))),\n    \"Defi data not supported by write_data_enum\");","typeGuard":"fn is_defi(d: &nautilus_model::data::Data) -> bool {\n    #[cfg(feature = \"defi\")]\n    { matches!(d, nautilus_model::data::Data::Defi(_)) }\n    #[cfg(not(feature = \"defi\"))]\n    { false }\n}","tryCatchPattern":"match catalog.write_data_enum(&data, None, None, None) {\n    Err(e) if e.to_string().contains(\"Data::Defi\") => route_to_defi_writer(&data)?,\n    other => other?,\n}","preventionTips":["Partition DeFi records into their own pipeline before catalog writes","Gate write calls behind feature-flag-aware filters","Read the write_data_enum docs to confirm which variants are supported"],"tags":["rust","persistence","parquet","unsupported-operation","defi"],"backgroundTag":"unsupported-operation","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}