cube-js/cube · error · UserError
FILTER_GROUP expects FILTER_PARAMS args to be passed. For ex
Error message
FILTER_GROUP expects FILTER_PARAMS args to be passed. For example FILTER_GROUP(FILTER_PARAMS.foo.bar.filter('bar'), FILTER_PARAMS.foo.jar.filter('jar')). But found: ${f} What it means
FILTER_GROUP() combines multiple FILTER_PARAMS conditions into one grouped filter. Every argument must be a FILTER_PARAMS arg object exposing __member(). Passing anything else (a raw string, SQL fragment, undefined, or result of a non-FILTER_PARAMS function) fails the check and throws this UserError.
Source
Thrown at packages/cubejs-schema-compiler/src/adapter/BaseQuery.js:5421
// eslint-disable-next-line prefer-spread
return filterParamArg.__column().apply(
null,
filterParams.map(allocateParam),
);
}
filterGroupFunction() {
const { allFilters } = this;
return this.filterGroupFunctionImpl(allFilters);
}
filterGroupFunctionImpl(allFilters) {
const allocateParam = this.paramAllocator.allocateParam.bind(this.paramAllocator);
const newGroupFilter = this.newGroupFilter.bind(this);
return (...filterParamArgs) => {
const groupMembers = filterParamArgs.map(f => {
if (!f.__member) {
throw new UserError(`FILTER_GROUP expects FILTER_PARAMS args to be passed. For example FILTER_GROUP(FILTER_PARAMS.foo.bar.filter('bar'), FILTER_PARAMS.foo.jar.filter('jar')). But found: ${f}`);
}
return f.__member();
});
const aliases = allFilters ?
allFilters
.map(v => (v.query ? v.query.allBackAliasMembersExceptSegments() : {}))
.reduce((a, b) => ({ ...a, ...b }), {})
: {};
// Filtering aliases that somehow relate to this group members
const aliasesForGroupMembers = Object.entries(aliases)
.filter(([key, value]) => groupMembers.includes(key))
.map(([_key, value]) => value);
const filter = BaseQuery.findAndSubTreeForFilterGroup(
newGroupFilter({ operator: 'and', values: allFilters }),
groupMembers,
newGroupFilter,
aliasesForGroupMembersView on GitHub (pinned to 7d981676b3)
Solutions
- Wrap every argument in FILTER_PARAMS.<cube>.<member>.filter('...') before passing to FILTER_GROUP
- Ensure each referenced member actually has a filter() defined via FILTER_PARAMS in the model
- Remove non-FILTER_PARAMS arguments or move them into the members' filter conditions
Example fix
// before
sql: `FILTER_GROUP(orders.status, ${FILTER_SQL})`
// after
sql: `FILTER_GROUP(FILTER_PARAMS.orders.status.filter('status'), FILTER_PARAMS.orders.region.filter('region'))` Defensive patterns
Strategy: validation
Validate before calling
function validateFilterGroupArgs(...args) {
if (!args.length || args.some(a => !a || typeof a.__member !== 'function'))
throw new Error('FILTER_GROUP args must be FILTER_PARAMS.<cube>.<member>.filter(...) results');
} Type guard
const isFilterParamMember = (f) => typeof f === 'object' && f !== null && typeof f.__member === 'function';
Try / catch
try { await cubeApi.query(q); } catch (e) { if (/FILTER_GROUP expects FILTER_PARAMS args/.test(e.message)) console.error('Wrap each arg in FILTER_PARAMS...filter()'); throw e; } Prevention
- Never pass raw strings or plain filters into FILTER_GROUP
- Build FILTER_GROUP args by spreading only FILTER_PARAMS.filter() results
- Type-check generated SQL templates that interpolate FILTER_GROUP
When it happens
Trigger: FILTER_GROUP('some string'), FILTER_GROUP(orders.bar.filter('x')) where orders.bar is not a FILTER_PARAMS arg, or FILTER_GROUP() with no args; nesting a plain filter expression inside FILTER_GROUP.
Common situations: Mixing normal filter helpers with FILTER_GROUP; forgetting to wrap members in FILTER_PARAMS.<cube>.<member>.filter(...); typos so the call chain returns undefined.
Related errors
- Can't parse date: '${from}'
- Can't parse date: '${to}'
- Can't parse date: '${dateString}'
- Invalid Job query format: ${error.message || error.toString(
- Cannot parse selector date range ${selector.dateRange}
AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02).
Data as JSON: /api/errors/9e563871a1cfb492.
Report an issue: GitHub.