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 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.

Source

Thrown at packages/cubejs-schema-compiler/src/compiler/transpilers/LightweightSymbolResolver.ts:20

import { CONTEXT_SYMBOLS, CURRENT_CUBE_CONSTANTS } from '../CubeSymbols';

type CubeSymbols = Record<string, Record<string, boolean>>;

export class LightweightSymbolResolver implements TranspilerSymbolResolver {
  public constructor(private symbols: CubeSymbols = {}) {
  }

  public setSymbols(symbols: CubeSymbols) {
    this.symbols = symbols;
  }

  public isCurrentCube(name): boolean {
    return CURRENT_CUBE_CONSTANTS.indexOf(name) >= 0;
  }

  public resolveSymbol(cubeName, name): any {
    if (name === 'USER_CONTEXT') {
      throw new Error('Support for USER_CONTEXT was removed, please migrate to SECURITY_CONTEXT.');
    }

    if (CONTEXT_SYMBOLS[name]) {
      return true;
    }

    const cube = this.symbols[this.isCurrentCube(name) ? cubeName : name];
    return cube || (this.symbols[cubeName] && this.symbols[cubeName][name]);
  }
}

View on GitHub (pinned to 7d981676b3)

Solutions

  1. Replace USER_CONTEXT with SECURITY_CONTEXT in the schema
  2. Use the equivalent field, e.g. filter: SECURITY_CONTEXT.user_id or via its .sql/attributes as documented
  3. Review the Cube SECURITY_CONTEXT docs for mapping of old USER_CONTEXT fields to new ones

Example fix

// before
filter: { member: 'Users.id', operator: 'equals', values: [USER_CONTEXT.id] }
// after
filter: { member: 'Users.id', operator: 'equals', values: [SECURITY_CONTEXT.user_id] }
Defensive patterns

Strategy: validation

Validate before calling

function assertNoUserContext(schemaSource) {
  if (/\bUSER_CONTEXT\b/.test(schemaSource)) {
    throw new Error('USER_CONTEXT is removed; migrate to SECURITY_CONTEXT');
  }
}

Try / catch

try {
  await compiler.compile();
} catch (e) {
  if (e.message.includes('USER_CONTEXT was removed')) {
    console.error('Replace USER_CONTEXT with SECURITY_CONTEXT in your schema files');
  }
  throw e;
}

Prevention

When it happens

Trigger: Referencing USER_CONTEXT (e.g. USER_CONTEXT.id) anywhere in a JS or YAML data model that gets compiled through resolveSymbol.

Common situations: Old schemas written before the SECURITY_CONTEXT migration; copying example code from outdated documentation or blog posts; upgrading Cube without updating schema files.

Related errors


AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02). Data as JSON: /api/errors/5399d0ad5de00f6e. Report an issue: GitHub.