cube-js/cube · error · Error
Expected only 2 parameters for timestamp filter but got: ${t
Error message
Expected only 2 parameters for timestamp filter but got: ${this.filterParams()} What it means
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.
Source
Thrown at packages/cubejs-schema-compiler/src/adapter/BaseFilter.ts:180
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()}`);
}
return this.allocateTimestampParam(p);
});
}
public allParamsRepeat(basePart) {
return this.filterParams().map(p => this.query.paramAllocator.allocateParamsForQuestionString(basePart, [p]));
}
public isArrayValues() {
return Array.isArray(this.values) && this.values.length > 1;
}
public containsWhere(column) {
return this.likeOr(column, false, 'contains');
}
public notContainsWhere(column) {View on GitHub (pinned to 7d981676b3)
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
Example fix
// before
{ member: 'Orders.createdAt', operator: 'inDateRange', values: ['2024-01-01','2024-02-01','2024-03-01'] }
// after
{ member: 'Orders.createdAt', operator: 'inDateRange', values: ['2024-01-01','2024-02-01'] } Defensive patterns
Strategy: validation
Validate before calling
function validateDateRange(td) {
if (td.dateRange && td.dateRange.length > 2) {
throw new Error(`dateRange for ${td.dimension} must have at most 2 values`);
}
}
query.timeDimensions?.forEach(validateDateRange); Type guard
function isValidDateRange(v) {
return v == null || (Array.isArray(v) && v.length === 2 && v.every(x => typeof x === 'string'));
} Try / catch
try {
await cubeApi.load(query);
} catch (e) {
if (e.message.includes('Expected only 2 parameters for timestamp filter')) {
console.error('dateRange has too many values:', e.message);
// trim range to first two entries and retry
}
throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: Frontend date pickers emitting extra range bounds; clients serializing multi-value arrays into a dateRange filter; programmatic query builders appending values without validating length.
Related errors
- Expected one parameter but nothing found
- Unsupported timestamp precision: ${this.query.timestampPreci
- Date range expected to be in ${DEFAULT_TS_FORMAT} format but
- compareDateRange can only exist for one timeDimension
- Granularity "${timeDimension.granularity}" not found in time
AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02).
Data as JSON: /api/errors/9da484a1b3070381.
Report an issue: GitHub.