nautechsystems/nautilus_trader · error

Continuous future `bar_types` request parameter must not be

Error message

Continuous future `bar_types` request parameter must not be empty

What it means

The `bar_types` request parameter for a continuous-future request contained no bar types after parsing and deduplication. At least one internally aggregated bar type must be requested to build a continuous series.

Source

Thrown at crates/data/src/engine/requests.rs:469

        let raw = value
            .as_str()
            .context("`bar_types` request parameter must contain strings")?;
        let bar_type =
            BarType::from_str(raw).context("failed to parse `bar_types` request parameter")?;

        if !bar_type.is_internally_aggregated() {
            anyhow::bail!(
                "Cannot request aggregated bars: {bar_type} must be internally aggregated"
            );
        }

        if !bar_types.contains(&bar_type) {
            bar_types.push(bar_type);
        }
    }

    if bar_types.is_empty() {
        anyhow::bail!("Continuous future `bar_types` request parameter must not be empty");
    }

    Ok(bar_types)
}

fn parse_adjustment_mode(value: Option<&Value>) -> anyhow::Result<ContinuousFutureAdjustmentType> {
    let Some(value) = value else {
        return Ok(ContinuousFutureAdjustmentType::default());
    };

    if let Some(raw) = value.as_str() {
        return ContinuousFutureAdjustmentType::from_str(raw)
            .with_context(|| format!("failed to parse `{CONTINUOUS_FUTURE_ADJUSTMENT_MODE}`"));
    }

    match value.as_u64() {
        Some(1) => Ok(ContinuousFutureAdjustmentType::BackwardSpread),
        Some(2) => Ok(ContinuousFutureAdjustmentType::ForwardSpread),

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Add at least one internally aggregated bar type to `bar_types` (e.g. "ES.C-2025Q1-CME-LAST-DAY").
  2. Check upstream code that constructs/filters the bar-type list so it cannot yield an empty array.
  3. Assert non-empty before issuing the request.

Example fix

// before
let params = json!({"bar_types": []});
// after
let params = json!({"bar_types": ["ES.C-2025Q1-CME-LAST-DAY"]});
Defensive patterns

Strategy: validation

Validate before calling

assert!(!bar_types.is_empty(), "bar_types must contain at least one internally aggregated bar type");

Prevention

When it happens

Trigger: Calling continuous_future_request_from_bars with `bar_types` set to an empty array or missing entirely (loop over empty raw array yields empty vec).

Common situations: Building request params programmatically where the bar-type list was filtered down to empty; forgetting the `bar_types` key; serializing an empty Vec from config.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/a214262196fa28be. Report an issue: GitHub.