cube-js/cube · error · Error

Expected one parameter but nothing found

Error message

Expected one parameter but nothing found

What it means

BaseFilter.firstParameter() returns the first bound parameter for a simple comparison filter (equals, notEquals, gt, gte, lt, lte). If filterParams() yields an empty array, there is no value to bind and the SQL would be malformed, so the filter throws before generating SQL. It signals that the filter was created without its required value.

Source

Thrown at packages/cubejs-schema-compiler/src/adapter/BaseFilter.ts:163

    return includes(this.camelizeOperator, DATE_OPERATORS);
  }

  public valuesArray() {
    return Array.isArray(this.values) ? this.values : [this.values];
  }

  public valuesContainNull() {
    return this.valuesArray().indexOf(null) !== -1;
  }

  public castParameter() {
    return '?';
  }

  public firstParameter() {
    const params = this.filterParams();
    if (!params.length) {
      throw new Error('Expected one parameter but nothing found');
    }

    return this.allocateCastParam(params[0]);
  }

  public allocateCastParam(param) {
    return this.query.paramAllocator.allocateParamsForQuestionString(this.castParameter(), [param]);
  }

  public allocateTimestampParam(param) {
    return this.query.paramAllocator.allocateParamsForQuestionString(this.query.timeStampParam(this), [param]);
  }

  public allocateTimestampParams() {
    return this.filterParams().map((p, i) => {
      if (i > 1) {
        throw new Error(`Expected only 2 parameters for timestamp filter but got: ${this.filterParams()}`);
      }

View on GitHub (pinned to 7d981676b3)

Solutions

  1. Ensure every filter object includes a non-empty values array: { member: 'Orders.total', operator: 'equals', values: [42] }
  2. Log the incoming query JSON to find the filter with missing values
  3. If values can be empty, use operator 'set'/'notSet' which require no parameters instead of equals
  4. For custom filter subclasses, make filterParams() return at least one value before firstParameter() is called

Example fix

// before
{ member: 'Orders.total', operator: 'equals', values: [] }
// after
{ member: 'Orders.total', operator: 'equals', values: [100] }
Defensive patterns

Strategy: validation

Validate before calling

function validateFilter(f) {
  const needsParam = ['equals','notEquals','gt','gte','lt','lte'].includes(f.operator);
  if (needsParam && (!Array.isArray(f.values) || f.values.length < 1)) {
    throw new Error(`Filter on ${f.member} with ${f.operator} requires a value`);
  }
}
query.filters?.forEach(validateFilter);

Try / catch

try {
  await cubeApi.load(query);
} catch (e) {
  if (e.message.includes('Expected one parameter but nothing found')) {
    // inspect e and the query for the filter missing values
    console.error('Filter missing value in query:', JSON.stringify(query.filters));
  }
  throw e;
}

Prevention

When it happens

Trigger: Building a query where a filter for a measure/dimension uses an operator requiring exactly one parameter but the filter's params array is empty — e.g. filter: { member: 'Orders.total', operator: 'equals' } with no 'values' key, an empty values: [], or a custom filter subclass whose filterParams() returns [].

Common situations: Client queries built dynamically where the value key is dropped or empty; query-orchestrator rewriting filters with null values; custom adapter filter implementations forgetting to populate params; date range filters mis-decomposed into single-param comparisons.

Related errors


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