{"record":{"id":"62feedc31f9776e9","repo":"cube-js/cube","slug":"expected-one-parameter-but-nothing-found","errorCode":null,"errorMessage":"Expected one parameter but nothing found","messagePattern":"Expected one parameter but nothing found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cubejs-schema-compiler/src/adapter/BaseFilter.ts","lineNumber":163,"sourceCode":"    return includes(this.camelizeOperator, DATE_OPERATORS);\n  }\n\n  public valuesArray() {\n    return Array.isArray(this.values) ? this.values : [this.values];\n  }\n\n  public valuesContainNull() {\n    return this.valuesArray().indexOf(null) !== -1;\n  }\n\n  public castParameter() {\n    return '?';\n  }\n\n  public firstParameter() {\n    const params = this.filterParams();\n    if (!params.length) {\n      throw new Error('Expected one parameter but nothing found');\n    }\n\n    return this.allocateCastParam(params[0]);\n  }\n\n  public allocateCastParam(param) {\n    return this.query.paramAllocator.allocateParamsForQuestionString(this.castParameter(), [param]);\n  }\n\n  public allocateTimestampParam(param) {\n    return this.query.paramAllocator.allocateParamsForQuestionString(this.query.timeStampParam(this), [param]);\n  }\n\n  public allocateTimestampParams() {\n    return this.filterParams().map((p, i) => {\n      if (i > 1) {\n        throw new Error(`Expected only 2 parameters for timestamp filter but got: ${this.filterParams()}`);\n      }","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-schema-compiler/src/adapter/BaseFilter.ts#L145-L181","documentation":"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.","triggerScenarios":"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 [].","commonSituations":"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.","solutions":["Ensure every filter object includes a non-empty values array: { member: 'Orders.total', operator: 'equals', values: [42] }","Log the incoming query JSON to find the filter with missing values","If values can be empty, use operator 'set'/'notSet' which require no parameters instead of equals","For custom filter subclasses, make filterParams() return at least one value before firstParameter() is called"],"exampleFix":"// before\n{ member: 'Orders.total', operator: 'equals', values: [] }\n// after\n{ member: 'Orders.total', operator: 'equals', values: [100] }","handlingStrategy":"validation","validationCode":"function validateFilter(f) {\n  const needsParam = ['equals','notEquals','gt','gte','lt','lte'].includes(f.operator);\n  if (needsParam && (!Array.isArray(f.values) || f.values.length < 1)) {\n    throw new Error(`Filter on ${f.member} with ${f.operator} requires a value`);\n  }\n}\nquery.filters?.forEach(validateFilter);","typeGuard":null,"tryCatchPattern":"try {\n  await cubeApi.load(query);\n} catch (e) {\n  if (e.message.includes('Expected one parameter but nothing found')) {\n    // inspect e and the query for the filter missing values\n    console.error('Filter missing value in query:', JSON.stringify(query.filters));\n  }\n  throw e;\n}","preventionTips":["Always include a non-empty values array for equals/notEquals/comparison operators","Use set/notSet operators for presence checks instead of equals with empty values","Validate query JSON against the Cube query schema on the client before sending","Never build filters programmatically without asserting param presence"],"tags":["schema-compiler","filter","sql-parameters","query"],"backgroundTag":"missing-filter-param","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}