{"record":{"id":"4791e5faf2f89b4d","repo":"nautechsystems/nautilus_trader","slug":"invalid-data-element-not-tradetick-was-data","errorCode":null,"errorMessage":"Invalid data element not `TradeTick`, was {data:?}","messagePattern":"Invalid data element not `TradeTick`, was (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/databento/src/historical.rs","lineNumber":713,"sourceCode":"                &record,\n                &mut metadata_cache,\n                &self.publisher_venue_map,\n                &sym_map,\n            )?;\n            let price_precision = self.resolve_cached_price_precision(\n                &instrument_id,\n                price_precision_arg,\n                &mut precision_cache,\n            )?;\n\n            let (data, data2) =\n                decode_record(&record, instrument_id, price_precision, None, true, true)?;\n\n            match (data, data2) {\n                (Some(Data::Trade(trade)), _) | (_, Some(Data::Trade(trade))) => result.push(trade),\n                (Some(_) | None, None) => {}\n                (None, Some(data)) => {\n                    anyhow::bail!(\"Invalid data element not `TradeTick`, was {data:?}\")\n                }\n                (Some(data), Some(_)) => {\n                    anyhow::bail!(\"Invalid data element not `TradeTick`, was {data:?}\")\n                }\n            }\n            Ok(())\n        };\n\n        match dbn_schema {\n            dbn::Schema::Trades => {\n                while let Some(msg) = decoder.decode_record::<dbn::TradeMsg>().await? {\n                    process_record(dbn::RecordRef::from(msg))?;\n                }\n            }\n            dbn::Schema::Mbp1 => {\n                while let Some(msg) = decoder.decode_record::<dbn::Mbp1Msg>().await? {\n                    process_record(dbn::RecordRef::from(msg))?;\n                }","sourceCodeStart":695,"sourceCodeEnd":731,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/databento/src/historical.rs#L695-L731","documentation":"During Databento historical trade fetching, each decoded record must decode to a `Data::Trade` variant. This error is raised when a record decodes to `None` for the primary data but yields a second non-Trade element (data2), i.e. the `(None, Some(data))` arm in `get_range_trades`. The decoder produced data the trade-fetcher cannot interpret as a trade tick, so it aborts rather than silently dropping records.","triggerScenarios":"Calling `get_range_trades` on a schema/request whose decoded records yield `data2` that is not a `Data::Trade` — e.g. a mismatched DBN schema producing records the decoder maps to a secondary non-trade element instead of `Data::Trade`.","commonSituations":"Requesting trades against a dataset/symbol whose underlying schema changed or was misinterpreted; decoding records from an unexpected Databento schema (e.g. MBO or OHLCV data reaching the trade pipeline); a Databento SDK version change altering record decoding.","solutions":["Verify the requested DBN schema for this call is a trade schema (Trades / Tcbbo), not OHLCV or MBO.","Check the symbol/dataset: ensure `get_range_trades` is only called for instruments that publish trade data.","Inspect the decoded element in the `{data:?}` message to identify which record type is actually being produced.","If data legitimately contains non-trade records, filter it before decoding or use the appropriate range method (e.g. get_range_bars)."],"exampleFix":"// before\nlet trades = client.get_range_trades(&params, ...)?;\n// after — ensure schema is trades\nparams.schema = Some(\"trades\"); // or \"tbbo\"/\"cbbo\" where supported\nlet trades = client.get_range_trades(&params, ...)?;","handlingStrategy":"validation","validationCode":"// Before calling, ensure the request schema is a trade schema\nassert!(matches!(params.schema.as_deref(), None | Some(\"trades\") | Some(\"tbbo\") | Some(\"cbbo\")),\n    \"get_range_trades requires a trade schema, got {:?}\", params.schema);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only call get_range_trades for schemas known to produce trade records","Use get_range_bars/get_range_quotes for their respective data types","Pin the databento/DBN dependency versions in lockstep with the adapter"],"tags":["databento","decoding","trade-tick","schema-mismatch"],"backgroundTag":"incompatible-source-type","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"}