{"record":{"id":"5399d0ad5de00f6e","repo":"cube-js/cube","slug":"support-for-user-context-was-removed-please-migra-5399d0","errorCode":null,"errorMessage":"Support for USER_CONTEXT was removed, please migrate to SECURITY_CONTEXT.","messagePattern":"Support for USER_CONTEXT was removed, please migrate to SECURITY_CONTEXT\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cubejs-schema-compiler/src/compiler/transpilers/LightweightSymbolResolver.ts","lineNumber":20,"sourceCode":"import { CONTEXT_SYMBOLS, CURRENT_CUBE_CONSTANTS } from '../CubeSymbols';\n\ntype CubeSymbols = Record<string, Record<string, boolean>>;\n\nexport class LightweightSymbolResolver implements TranspilerSymbolResolver {\n  public constructor(private symbols: CubeSymbols = {}) {\n  }\n\n  public setSymbols(symbols: CubeSymbols) {\n    this.symbols = symbols;\n  }\n\n  public isCurrentCube(name): boolean {\n    return CURRENT_CUBE_CONSTANTS.indexOf(name) >= 0;\n  }\n\n  public resolveSymbol(cubeName, name): any {\n    if (name === 'USER_CONTEXT') {\n      throw new Error('Support for USER_CONTEXT was removed, please migrate to SECURITY_CONTEXT.');\n    }\n\n    if (CONTEXT_SYMBOLS[name]) {\n      return true;\n    }\n\n    const cube = this.symbols[this.isCurrentCube(name) ? cubeName : name];\n    return cube || (this.symbols[cubeName] && this.symbols[cubeName][name]);\n  }\n}\n","sourceCodeStart":2,"sourceCodeEnd":31,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-schema-compiler/src/compiler/transpilers/LightweightSymbolResolver.ts#L2-L31","documentation":"The lightweight symbol resolver refuses the USER_CONTEXT symbol in data models because Cube removed it in favor of SECURITY_CONTEXT. This is an intentional migration guard forcing schema authors to update deprecated context references.","triggerScenarios":"Referencing USER_CONTEXT (e.g. USER_CONTEXT.id) anywhere in a JS or YAML data model that gets compiled through resolveSymbol.","commonSituations":"Old schemas written before the SECURITY_CONTEXT migration; copying example code from outdated documentation or blog posts; upgrading Cube without updating schema files.","solutions":["Replace USER_CONTEXT with SECURITY_CONTEXT in the schema","Use the equivalent field, e.g. filter: SECURITY_CONTEXT.user_id or via its .sql/attributes as documented","Review the Cube SECURITY_CONTEXT docs for mapping of old USER_CONTEXT fields to new ones"],"exampleFix":"// before\nfilter: { member: 'Users.id', operator: 'equals', values: [USER_CONTEXT.id] }\n// after\nfilter: { member: 'Users.id', operator: 'equals', values: [SECURITY_CONTEXT.user_id] }","handlingStrategy":"validation","validationCode":"function assertNoUserContext(schemaSource) {\n  if (/\\bUSER_CONTEXT\\b/.test(schemaSource)) {\n    throw new Error('USER_CONTEXT is removed; migrate to SECURITY_CONTEXT');\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await compiler.compile();\n} catch (e) {\n  if (e.message.includes('USER_CONTEXT was removed')) {\n    console.error('Replace USER_CONTEXT with SECURITY_CONTEXT in your schema files');\n  }\n  throw e;\n}","preventionTips":["Grep your data models for USER_CONTEXT during upgrades","Standardize on SECURITY_CONTEXT in new schemas","Add a CI lint rule banning USER_CONTEXT tokens"],"tags":["deprecation","security-context","schema"],"backgroundTag":"removed-api-migration","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}