{"record":{"id":"707f9f8acd2aa349","repo":"nautechsystems/nautilus_trader","slug":"invalid-baraggregation-for-request-was-aggrega","errorCode":null,"errorMessage":"Invalid `BarAggregation` for request, was {aggregation}","messagePattern":"Invalid `BarAggregation` for request, was (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/databento/src/historical.rs","lineNumber":778,"sourceCode":"        &self,\n        params: RangeQueryParams,\n        aggregation: BarAggregation,\n        timestamp_on_close: bool,\n    ) -> anyhow::Result<Vec<Bar>> {\n        let symbols: Vec<&str> = params.symbols.iter().map(String::as_str).collect();\n        check_consistent_symbology(&symbols)?;\n\n        let first_symbol = params\n            .symbols\n            .first()\n            .ok_or_else(|| anyhow::anyhow!(\"No symbols provided\"))?;\n        let stype_in = infer_symbology_type(first_symbol);\n        let schema = match aggregation {\n            BarAggregation::Second => dbn::Schema::Ohlcv1S,\n            BarAggregation::Minute => dbn::Schema::Ohlcv1M,\n            BarAggregation::Hour => dbn::Schema::Ohlcv1H,\n            BarAggregation::Day => dbn::Schema::Ohlcv1D,\n            _ => anyhow::bail!(\"Invalid `BarAggregation` for request, was {aggregation}\"),\n        };\n\n        let end = params.end.unwrap_or_else(|| self.clock.get_time_ns());\n        let time_range = get_date_time_range(params.start, end)?;\n\n        let range_params = GetRangeParams::builder()\n            .dataset(params.dataset)\n            .date_time_range(time_range)\n            .symbols(symbols)\n            .stype_in(stype_in)\n            .schema(schema)\n            .maybe_limit(params.limit.and_then(NonZeroU64::new))\n            .build();\n\n        let price_precision_arg = params.price_precision;\n\n        let mut client = (*self.inner).clone();\n        let mut decoder = client","sourceCodeStart":760,"sourceCodeEnd":796,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/databento/src/historical.rs#L760-L796","documentation":"`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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nlet bars = client.get_range_bars(&params, BarAggregation::Week)?;\n// after\nif !matches!(aggregation, BarAggregation::Second | BarAggregation::Minute | BarAggregation::Hour | BarAggregation::Day) {\n    anyhow::bail!(\"aggregation {:?} unsupported by Databento historical\", aggregation);\n}\nlet bars = client.get_range_bars(&params, aggregation)?;","handlingStrategy":"validation","validationCode":"SUPPORTED = {\"second\", \"minute\", \"hour\", \"day\"}\nassert aggregation.name.lower() in SUPPORTED, f\"Databento historical supports only {SUPPORTED}, got {aggregation}\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["databento","bar-aggregation","unsupported-value","historical-data"],"backgroundTag":"invalid-enum-value","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}