nautechsystems/nautilus_trader · error
Invalid `BarAggregation` for request, was {aggregation}
Error message
Invalid `BarAggregation` for request, was {aggregation} What it means
`get_range_bars` maps a `BarAggregation` to a Databento OHLCV schema only for Second, Minute, Hour, and Day. Any other aggregation value (e.g. MinuteBar variants, Volume-based, Tick-based, Week, Month) has no Databento OHLCV schema mapping and causes this bail.
Source
Thrown at crates/adapters/databento/src/historical.rs:778
&self,
params: RangeQueryParams,
aggregation: BarAggregation,
timestamp_on_close: bool,
) -> anyhow::Result<Vec<Bar>> {
let symbols: Vec<&str> = params.symbols.iter().map(String::as_str).collect();
check_consistent_symbology(&symbols)?;
let first_symbol = params
.symbols
.first()
.ok_or_else(|| anyhow::anyhow!("No symbols provided"))?;
let stype_in = infer_symbology_type(first_symbol);
let schema = match aggregation {
BarAggregation::Second => dbn::Schema::Ohlcv1S,
BarAggregation::Minute => dbn::Schema::Ohlcv1M,
BarAggregation::Hour => dbn::Schema::Ohlcv1H,
BarAggregation::Day => dbn::Schema::Ohlcv1D,
_ => anyhow::bail!("Invalid `BarAggregation` for request, was {aggregation}"),
};
let end = params.end.unwrap_or_else(|| self.clock.get_time_ns());
let time_range = get_date_time_range(params.start, end)?;
let range_params = GetRangeParams::builder()
.dataset(params.dataset)
.date_time_range(time_range)
.symbols(symbols)
.stype_in(stype_in)
.schema(schema)
.maybe_limit(params.limit.and_then(NonZeroU64::new))
.build();
let price_precision_arg = params.price_precision;
let mut client = (*self.inner).clone();
let mut decoder = clientView on GitHub (pinned to 18893faf8b)
Solutions
- Restrict requests to Second, Minute, Hour, or Day aggregations.
- Fetch a finer native interval and aggregate locally (e.g. fetch minute bars and build weekly bars client-side).
- Validate the aggregation parameter at the call site before invoking `get_range_bars`.
- If the data source is not Databento, route the request to an adapter that supports the aggregation.
Example fix
// before
let bars = client.get_range_bars(¶ms, BarAggregation::Week)?;
// after
if !matches!(aggregation, BarAggregation::Second | BarAggregation::Minute | BarAggregation::Hour | BarAggregation::Day) {
anyhow::bail!("aggregation {:?} unsupported by Databento historical", aggregation);
}
let bars = client.get_range_bars(¶ms, aggregation)?; Defensive patterns
Strategy: validation
Validate before calling
SUPPORTED = {"second", "minute", "hour", "day"}
assert aggregation.name.lower() in SUPPORTED, f"Databento historical supports only {SUPPORTED}, got {aggregation}" Prevention
- Constrain user/config-supplied aggregations to Databento-supported intervals
- Implement client-side aggregation for week/month/tick/volume bars
- Validate aggregation when building request parameters, not at fetch time
When it happens
Trigger: Calling `get_range_bars` with `aggregation` set to anything other than `BarAggregation::Second`, `::Minute`, `::Hour`, or `::Day` — e.g. tick/volume aggregations or week/month aggregations.
Common situations: Requesting volume- or tick-aggregated bars from Databento historical (which only serves fixed OHLCV intervals); passing week/month bars; passing an aggregation enum from user config that Databento can't serve natively.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Unsupported second interval: {step}s
- Unsupported minute interval: {step}m
- Chart function must be callable, was {type(f)}
- Unsupported bar specification for AX: {step}-{:?}
- Unsupported time in force: {:?}, AX supports GTC, IOC, and D
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/707f9f8acd2aa349.
Report an issue: GitHub.