{"record":{"id":"9da484a1b3070381","repo":"cube-js/cube","slug":"expected-only-2-parameters-for-timestamp-filter-bu","errorCode":null,"errorMessage":"Expected only 2 parameters for timestamp filter but got: ${this.filterParams()}","messagePattern":"Expected only 2 parameters for timestamp filter but got: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cubejs-schema-compiler/src/adapter/BaseFilter.ts","lineNumber":180,"sourceCode":"    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      }\n      return this.allocateTimestampParam(p);\n    });\n  }\n\n  public allParamsRepeat(basePart) {\n    return this.filterParams().map(p => this.query.paramAllocator.allocateParamsForQuestionString(basePart, [p]));\n  }\n\n  public isArrayValues() {\n    return Array.isArray(this.values) && this.values.length > 1;\n  }\n\n  public containsWhere(column) {\n    return this.likeOr(column, false, 'contains');\n  }\n\n  public notContainsWhere(column) {","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-schema-compiler/src/adapter/BaseFilter.ts#L162-L198","documentation":"Timestamp (date range) filters accept at most two parameters — a 'from' and a 'to' value. allocateTimestampParams() maps filterParams() and throws if a third parameter is present. This guards against producing an invalid SQL time-range comparison.","triggerScenarios":"Passing more than two values in a date-range filter, e.g. { member: 'Orders.createdAt', operator: 'inDateRange', values: ['2024-01-01','2024-02-01','2024-03-01'] }, or calling allocateTimestampParams on a filter built with multiple values via [from,to], [before], or [after] decomposition where extra params survive.","commonSituations":"Frontend date pickers emitting extra range bounds; clients serializing multi-value arrays into a dateRange filter; programmatic query builders appending values without validating length.","solutions":["Ensure date-range filter values contain at most two entries: ['2024-01-01','2024-02-01']","Split multi-period requests into separate queries or use multiple filter groups","Validate user-supplied date range inputs on the client before sending the query"],"exampleFix":"// before\n{ member: 'Orders.createdAt', operator: 'inDateRange', values: ['2024-01-01','2024-02-01','2024-03-01'] }\n// after\n{ member: 'Orders.createdAt', operator: 'inDateRange', values: ['2024-01-01','2024-02-01'] }","handlingStrategy":"validation","validationCode":"function validateDateRange(td) {\n  if (td.dateRange && td.dateRange.length > 2) {\n    throw new Error(`dateRange for ${td.dimension} must have at most 2 values`);\n  }\n}\nquery.timeDimensions?.forEach(validateDateRange);","typeGuard":"function isValidDateRange(v) {\n  return v == null || (Array.isArray(v) && v.length === 2 && v.every(x => typeof x === 'string'));\n}","tryCatchPattern":"try {\n  await cubeApi.load(query);\n} catch (e) {\n  if (e.message.includes('Expected only 2 parameters for timestamp filter')) {\n    console.error('dateRange has too many values:', e.message);\n    // trim range to first two entries and retry\n  }\n  throw e;\n}","preventionTips":["Cap date range pickers to from/to pairs","Validate dateRange length === 2 before sending timeDimensions","Split multi-period analysis into multiple queries","Test query builders with edge-case input arrays"],"tags":["schema-compiler","filter","timestamp","date-range","query"],"backgroundTag":"invalid-date-range-filter","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}