cube-js/cube · error · UserError
Filter for ${column} is required
Error message
Filter for ${column} is required What it means
The `requiredFilter` method of a filter proxy asserts that a filter parameter value was actually supplied. When the compiled filter method is invoked without a paramValue (no filter passed for the column), it throws this UserError. It lets schema authors declare members that cannot be queried without a mandatory filter (row-level safety, sharding by tenant, etc.).
Source
Thrown at packages/cubejs-schema-compiler/src/compiler/CubeSymbols.ts:1664
return column(values);
} else {
return `${column} IN (${values.join(', ')})`;
}
} else {
const value = allocateParam(paramValue);
if (typeof column === 'function') {
return column(value);
} else {
return `${column} = ${value}`;
}
}
} else {
return '1 = 1';
}
},
requiredFilter: (column) => {
if (!paramValue) {
throw new UserError(`Filter for ${column} is required`);
}
return methods(paramValue).filter(column);
},
unsafeValue: () => paramValue,
toString: () => {
if (paramValue !== undefined && paramValue !== null) {
return Array.isArray(paramValue)
? paramValue.map(allocateParam).join(',')
: String(allocateParam(paramValue));
}
return '';
},
[Symbol.toPrimitive]: () => {
if (paramValue !== undefined && paramValue !== null) {
return Array.isArray(paramValue)
? paramValue.map(allocateParam).join(',')
: String(allocateParam(paramValue));
}View on GitHub (pinned to 7d981676b3)
Solutions
- Add the required filter to the query (e.g. `filters: [{ member: 'Cube.tenantId', operator: 'equals', values: ['acme'] }]`).
- Set a default/required filter at the cube or security-context level so it is always injected.
- If the filter is no longer truly mandatory, replace `requiredFilter` with a regular filter expression.
- Educate API consumers / update the dashboard to always send the filter.
Example fix
// query before (throws)
{ measures: ['Orders.total'], timezone: 'UTC' }
// after
{ measures: ['Orders.total'], filters: [{ member: 'Orders.status', operator: 'equals', values: ['completed'] }] } Defensive patterns
Strategy: try-catch
Validate before calling
// ensure the query includes the required filter before sending
const required = 'Orders.status';
if (!query.filters?.some(f => f.member === required)) {
query.filters = [...(query.filters || []), { member: required, operator: 'equals', values: ['completed'] }];
} Try / catch
try { const r = await cubeApi.load(query); } catch (e) { if (/Filter for .* is required/.test(e.message)) { console.error(`Add filter on: ${e.message.match(/Filter for (.*) is required/)[1]}`); } throw e; } Prevention
- Document required-filter members for API consumers
- Inject tenant/date filters from security context in config
- Include default filters in dashboards and embedded apps
When it happens
Trigger: A cube defines `alwaysFilter`/required filter usage via `FILTER_PARAMS.requiredFilter('column')` or a member marked as requiring a filter, and a query is executed against that member without including a filter on that column.
Common situations: Multi-tenant tables where every query must filter by tenant_id; time-partitioned tables requiring a date range; dashboards that omit the default filter; API clients querying the member directly without the guard filter.
Related errors
- Filter for ${column} is required
- maskedMembers cannot be provided in the query
- Data blending query granularities must match
- Data blending query without granularity is not supported
- Expected one parameter but nothing found
AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02).
Data as JSON: /api/errors/eabdff2361af8245.
Report an issue: GitHub.