{"record":{"id":"8105ea4ef8c26b07","repo":"nautechsystems/nautilus_trader","slug":"composite-bar-types-are-not-supported-for-request","errorCode":null,"errorMessage":"Composite bar types are not supported for `request_bars`, was {bar_type}; request aggregation via the `bar_types` params instead","messagePattern":"Composite bar types are not supported for `request_bars`, was (.+?); request aggregation via the `bar_types` params instead","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/common/src/actor/data_actor.rs","lineNumber":5670,"sourceCode":"    /// Requests bars for the actor.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if input parameters are invalid.\n    #[expect(clippy::too_many_arguments)]\n    pub fn request_bars(\n        &self,\n        bar_type: BarType,\n        start: Option<Timestamp>,\n        end: Option<Timestamp>,\n        limit: Option<NonZeroUsize>,\n        client_id: Option<ClientId>,\n        params: Option<Params>,\n        handler: ShareableMessageHandler,\n    ) -> anyhow::Result<UUID4> {\n        self.check_registered();\n\n        anyhow::ensure!(\n            bar_type.is_standard(),\n            \"Composite bar types are not supported for `request_bars`, was {bar_type}; \\\n             request aggregation via the `bar_types` params instead\",\n        );\n\n        let now = self.clock_ref().utc_now();\n        check_timestamps(now, start, end)?;\n\n        let request_id = UUID4::new();\n        let command = RequestCommand::Bars(RequestBars {\n            bar_type,\n            start,\n            end,\n            limit,\n            client_id,\n            request_id,\n            ts_init: now.into(),\n            params,","sourceCodeStart":5652,"sourceCodeEnd":5688,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/common/src/actor/data_actor.rs#L5652-L5688","documentation":"`DataActor.request_bars` only accepts standard bar types; `anyhow::ensure!(bar_type.is_standard(), ...)` rejects composite bar types because historical bar requests must go to an external data client with an aggregatable spec, while composite bars are aggregated internally. The message tells you to request the base (standard) bars via the `bar_types` parameter and let internal aggregation build the composite bars instead.","triggerScenarios":"Calling an actor's `request_bars` with a `BarType` constructed with aggregation source/internal composite semantics (e.g. `BarType::new(..., AggregationSource::Internal)` or a composite spec) rather than a standard externally-sourced bar type.","commonSituations":"Building bar types with `BarType.from_str` strings containing composite/internal markers and passing them to `request_bars`; confusing `request_bars` (historical data from a client) with subscribing to internally aggregated composite bars; porting code that subscribed to composite bars and assuming request works the same way.","solutions":["Request the underlying standard bar type in `request_bars` instead of the composite bar type.","Pass the desired composite/aggregated bar types via the `bar_types` parameter so internal aggregation is used.","Ensure the BarType is created with a standard spec and external aggregation source (e.g. `BarType::new(instrument_id, spec, AggregationSource::External)`)."],"exampleFix":"// before\nlet composite = BarType::new(instrument_id, spec_internal, AggregationSource::Internal);\nself.request_bars(composite);\n// after\nlet standard = BarType::new(instrument_id, spec, AggregationSource::External);\nself.request_bars(standard); // pass composite types via `bar_types` param for aggregation","handlingStrategy":"validation","validationCode":"python\nif not bar_type.is_standard():\n    raise ValueError(\n        f\"{bar_type} is composite; request the standard bar type and aggregate via bar_types param\"\n    )\nactor.request_bars(standard_bar_type, bar_types=[bar_type])","typeGuard":"python\ndef is_standard_bar_type(bar_type: BarType) -> bool:\n    return bar_type.is_standard()","tryCatchPattern":"python\ntry:\n    await self.request_bars(bar_type)\nexcept Exception as e:\n    if \"Composite bar types are not supported\" in str(e):\n        base = BarType.from_str(str(bar_type).split(\"*\")[0])  # request the standard base\n        await self.request_bars(base, bar_types=[bar_type])\n    else:\n        raise","preventionTips":["Always build request_bars arguments with AggregationSource::External / standard specs.","Keep internally aggregated (composite) bar types for subscribe/handler paths, not request paths.","Use BarType::from_str only with standard-format strings for requests.","Add an is_standard() assertion in helpers that wrap request_bars.","Review the DataActor docs distinguishing historical requests from internal aggregation."],"tags":["data","bars","validation","actor"],"backgroundTag":"unsupported-operation","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"}