{"record":{"id":"52b5b864c8990e30","repo":"nautechsystems/nautilus_trader","slug":"no-continuous-future-subscription-state-for-targe","errorCode":null,"errorMessage":"No continuous future subscription state for {target_bar_type}","messagePattern":"No continuous future subscription state for (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/data/src/engine/mod.rs","lineNumber":5442,"sourceCode":"            )\n        })?;\n        let adjustment = request.adjustment_for_segment(segment_index);\n        aggregator\n            .borrow_mut()\n            .set_adjustment(adjustment, request.adjustment_mode);\n        Ok(())\n    }\n\n    fn apply_continuous_future_subscription_adjustment_for(\n        &self,\n        target_bar_type: BarType,\n        segment_index: usize,\n    ) -> anyhow::Result<()> {\n        let Some(state) = self\n            .continuous_future_subscriptions\n            .get(&target_bar_type.standard())\n        else {\n            anyhow::bail!(\"No continuous future subscription state for {target_bar_type}\");\n        };\n        self.apply_continuous_future_subscription_adjustment(&state.request, segment_index)\n    }\n\n    fn subscribe_continuous_future_source(\n        &mut self,\n        target_bar_type: BarType,\n        source: ContinuousFutureSource,\n        segment_instrument_id: InstrumentId,\n    ) -> BarAggregatorSubscription {\n        let key = bar_aggregator_key(target_bar_type, None);\n        let aggregator = self\n            .bar_aggregators\n            .get(&key)\n            .cloned()\n            .expect(\"aggregator was created before subscribe_continuous_future_source\");\n\n        let subscription = match source {","sourceCodeStart":5424,"sourceCodeEnd":5460,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/data/src/engine/mod.rs#L5424-L5460","documentation":"Applying a continuous future roll adjustment for a given segment requires existing subscription state keyed by the target bar type's standard form. When apply_continuous_future_subscription_adjustment looks up continuous_future_subscriptions and finds no entry, the internal bookkeeping for that subscription is missing — usually because the subscription was never registered or was already unsubscribed.","triggerScenarios":"Calling apply_continuous_future_subscription_adjustment (via roll/segment update paths) with a target_bar_type that has no entry in engine.continuous_future_subscriptions — e.g. after unsubscribe, before subscribe, or with a bar type string that differs in its standard form.","commonSituations":"Re-applying adjustments after an unsubscribe; passing a slightly different BarType spelling (price type, step, or aggregation mismatch) than the one subscribed; engine state reset between subscribe and segment processing.","solutions":["Subscribe to the continuous future bar type first so the subscription state is created, then apply adjustments.","Use the exact same BarType (standard form) as passed to the original subscription.","Check engine.continuous_future_subscriptions for the key before requesting a segment adjustment."],"exampleFix":"// before\nengine.apply_continuous_future_segment_adjustment(&other_bar_type, segment_index)?; // no state\n// after\nassert!(engine.continuous_future_subscriptions.contains_key(&bar_type.standard()));\nengine.apply_continuous_future_segment_adjustment(&bar_type, segment_index)?;","handlingStrategy":"type-guard","validationCode":"if !engine.continuous_future_subscriptions.contains_key(&bar_type.standard()) {\n    // subscribe first or skip the segment adjustment\n}","typeGuard":"fn has_continuous_state(engine: &DataEngine, bt: &BarType) -> bool {\n    engine.continuous_future_subscriptions.contains_key(&bt.standard())\n}","tryCatchPattern":"match engine.apply_continuous_future_segment_adjustment(&bar_type, idx) {\n    Err(e) if e.to_string().contains(\"No continuous future subscription state\") => {\n        engine.subscribe_continuous_future_bars(&sub_cmd)?;\n        engine.apply_continuous_future_segment_adjustment(&bar_type, idx)?;\n    }\n    r => r?,\n}","preventionTips":["Track subscription lifetime: never apply adjustments after unsubscribing","Always reuse the exact BarType used at subscription time","Keep engine state alive across the whole continuous series lifecycle"],"tags":["rust","data-engine","futures","subscription-state"],"backgroundTag":"record-not-found","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"}