nautechsystems/nautilus_trader · error
Invalid data element not `Bar`, was {data:?}
Error message
Invalid data element not `Bar`, was {data:?} What it means
In `get_range_bars`, each decoded record must decode to `Some(Data::Bar)`. If decoding yields `None` or any non-bar `Data` variant, the match falls to the catch-all arm and bails. This means the record stream for a bar request did not contain bar data.
Source
Thrown at crates/adapters/databento/src/historical.rs:835
&instrument_id,
price_precision_arg,
&mut precision_cache,
)?;
let (data, _) = decode_record(
&record,
instrument_id,
price_precision,
None,
false, // Not applicable
timestamp_on_close,
)?;
match data {
Some(Data::Bar(bar)) => {
result.push(bar);
}
_ => anyhow::bail!("Invalid data element not `Bar`, was {data:?}"),
}
}
Ok(result)
}
/// Fetches imbalance data for the given parameters.
///
/// # Errors
///
/// Returns an error if the API request or data processing fails.
pub async fn get_range_imbalance(
&self,
params: RangeQueryParams,
) -> anyhow::Result<Vec<DatabentoImbalance>> {
let symbols: Vec<&str> = params.symbols.iter().map(String::as_str).collect();
check_consistent_symbology(&symbols)?;
View on GitHub (pinned to 18893faf8b)
Solutions
- Verify the aggregation maps to the intended OHLCV schema (Ohlcv1S/1M/1H/1D).
- Inspect the `{data:?}` value in the message to see what was actually decoded.
- Ensure the dataset/publisher actually serves OHLCV data for the requested instrument.
- Align the databento-rs DBN version with the one this adapter was built against.
Example fix
// before
// schema resolved to trades but called get_range_bars
let bars = client.get_range_bars(¶ms, BarAggregation::Minute)?;
// after
params.schema = Some("ohlcv-1m");
let bars = client.get_range_bars(¶ms, BarAggregation::Minute)?; Defensive patterns
Strategy: validation
Validate before calling
// Ensure the request is actually a bar request before decoding
assert params.schema.startswith("ohlcv"), f"bar fetch requires ohlcv schema, got {params.schema}" Prevention
- Match the schema to the aggregation mapping (Ohlcv1S/1M/1H/1D)
- Do not reuse a trade/quote request's params for bar fetching
- Verify dataset serves OHLCV for the requested symbols
When it happens
Trigger: Calling `get_range_bars` when the resolved schema is not an OHLCV schema, or the record fails to decode into a bar (e.g. a trade/quote record reaching the bar decode path, or None from decode_record).
Common situations: Schema/aggregation mismatch causing trade records to enter the bar pipeline; datasets or record types unsupported by the decoder; Databento SDK version change altering record decoding.
Understand the failure class
Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.
Related errors
- Invalid data element not `TradeTick`, was {data:?}
- DBN message type is not currently supported
- DBN message type is not currently supported
- Error decoding `stype_in_symbol`: {e}
- Error decoding `stype_out_symbol`: {e}
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/deb44fc8d4b2e952.
Report an issue: GitHub.