cube-js/cube · error · UserError

Operator required for filter: ${JSON.stringify(f)}

Error message

Operator required for filter: ${JSON.stringify(f)}

What it means

Validation guard in normalizeQueryFilters: a filter object in the query's filter array lacks the required `operator` property. It fires for any leaf filter (not part of or/and groups) submitted without an operator, before operator whitelist checking.

Source

Thrown at packages/cubejs-api-gateway/src/query.js:369

  }

  return filter;
};

const normalizeQueryFilters = (filter, timezone) => (
  filter.map(f => {
    const res = { ...f };
    if (f.or) {
      res.or = normalizeQueryFilters(f.or, timezone);
      return res;
    }
    if (f.and) {
      res.and = normalizeQueryFilters(f.and, timezone);
      return res;
    }

    if (!f.operator) {
      throw new UserError(`Operator required for filter: ${JSON.stringify(f)}`);
    }

    if (operators.indexOf(f.operator) === -1) {
      throw new UserError(`Operator ${f.operator} not supported for filter: ${JSON.stringify(f)}`);
    }

    if ((!f.values || f.values.length === 0) && ['set', 'notSet', 'measureFilter'].indexOf(f.operator) === -1) {
      throw new UserError(`Values required for filter: ${JSON.stringify(f)}`);
    }

    if (f.values) {
      res.values = f.values.map(v => (v != null ? v.toString() : v));
    }

    if (f.dimension) {
      res.member = f.dimension;
      delete res.dimension;
    }

View on GitHub (pinned to 7d981676b3)

Solutions

  1. Add a valid operator field (e.g. "equals", "contains", "inDateRange") to the filter object.
  2. Check that the filter was not corrupted by client-side serialization dropping the operator key.
  3. If the filter is meant to be optional, remove it from the query entirely.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/cubejs-api-gateway/src/query.js:369 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02). Data as JSON: /api/errors/fa33917686d11a00. Report an issue: GitHub.