cube-js/cube · error · Error
Support for USER_CONTEXT was removed, please migrate to SECU
Error message
Support for USER_CONTEXT was removed, please migrate to SECURITY_CONTEXT.
What it means
The old SECURITY_CONTEXT predecessor symbol USER_CONTEXT was removed from the schema compiler. resolveSymbol throws this Error when a data model references USER_CONTEXT so the author migrates to SECURITY_CONTEXT. There is no fallback: the symbol no longer resolves.
Source
Thrown at packages/cubejs-schema-compiler/src/compiler/CubeSymbols.ts:1405
},
toString() {
return '';
}
})
})
});
}
});
}
protected filterGroupFunctionDep() {
return (...filterParamArgs) => '';
}
public resolveSymbol(cubeName, name: string) {
const { sqlResolveFn, contextSymbols, collectJoinHints, depsResolveFn, currResolveIndexFn } = this.resolveSymbolsCallContext || {};
if (name === 'USER_CONTEXT') {
throw new Error('Support for USER_CONTEXT was removed, please migrate to SECURITY_CONTEXT.');
}
if (CONTEXT_SYMBOLS[name]) {
// always resolves if contextSymbols aren't passed for transpile step
const symbol = contextSymbols?.[CONTEXT_SYMBOLS[name]] || {};
// eslint-disable-next-line no-underscore-dangle
symbol._objectWithResolvedProperties = true;
return symbol;
}
// In proxied subProperty flow `name` will be set to parent dimension|measure name,
// so there will be no cube = this.symbols[cubeName : name] found, but potentially
// during cube definition evaluation some other deeper subProperty may be requested.
// To distinguish such cases we pass the right now requested property name to
// cubeReferenceProxy, so later if subProperty is requested we'll have all the required
// information to construct the response.
let cube = this.symbols[this.isCurrentCube(name) ? cubeName : name];
if (sqlResolveFn) {View on GitHub (pinned to 7d981676b3)
Solutions
- Replace every USER_CONTEXT reference with SECURITY_CONTEXT in all data model files.
- Verify the security context keys you access exist in your JWT/security context (SECURITY_CONTEXT is null-safe but keys must match).
- Search the repository for `USER_CONTEXT` and run the test suite to confirm compilation succeeds.
Example fix
// before
filter: { sql: `\${CUBE}.tenantId = '\${USER_CONTEXT.tenantId}'` }
// after
filter: { sql: `\${CUBE}.tenantId = '\${SECURITY_CONTEXT.tenantId}'` } Defensive patterns
Strategy: validation
Validate before calling
grep -rn 'USER_CONTEXT' schema/ && echo 'Found legacy USER_CONTEXT usage - migrate to SECURITY_CONTEXT'
Try / catch
try { await compiler.compile(); } catch (e) { if (/USER_CONTEXT was removed/.test(e.message)) { console.error('Migrate USER_CONTEXT -> SECURITY_CONTEXT'); } throw e; } Prevention
- Add a lint/grep rule banning USER_CONTEXT in schema folders
- Review release notes before major upgrades
- Use SECURITY_CONTEXT in all new data models
When it happens
Trigger: A cube/view/join SQL or filter references `${USER_CONTEXT.something}` (e.g. `filter: { sql: '\${CUBE}.userId = \'\${USER_CONTEXT.id}\'' }`). Compilation calls resolveSymbol('USER_CONTEXT') and throws immediately.
Common situations: Upgrading an old Cube project from a pre-SECURITY_CONTEXT version; copying legacy schema examples from old tutorials; multi-tenant filters written years ago never migrated.
Related errors
- Filter for ${column} is required
- Expected one parameter but nothing found
- Expected only 2 parameters for timestamp filter but got: ${t
- Unsupported timestamp precision: ${this.query.timestampPreci
- Unsupported measure type replacement for ${sourceMeasure}: $
AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02).
Data as JSON: /api/errors/afb1749287f45c4b.
Report an issue: GitHub.