cube-js/cube · error · UserError

Cube '${cubeAndName[0]}' not found for path '${path}'

Error message

Cube '${cubeAndName[0]}' not found for path '${path}'

What it means

cubeNameFromPath splits a member path on '.' and verifies the first segment is a known cube in evaluatedCubes. If the cube part of the path isn't found (typo, not compiled, or removed), a UserError naming the cube and full path is thrown.

Source

Thrown at packages/cubejs-schema-compiler/src/compiler/CubeEvaluator.ts:1043

    if (!Array.isArray(path)) {
      path = path.split('.');
    }

    if (path.length < 2) {
      throw new UserError(`Not full member name provided: ${path[0]}`);
    }

    return path.slice(-2).join('.');
  }

  public cubeFromPath(path: string): EvaluatedCube {
    return this.evaluatedCubes[this.cubeNameFromPath(path)];
  }

  public cubeNameFromPath(path: string) {
    const cubeAndName = path.split('.');
    if (!this.evaluatedCubes[cubeAndName[0]]) {
      throw new UserError(`Cube '${cubeAndName[0]}' not found for path '${path}'`);
    }
    return cubeAndName[0];
  }

  public isInstanceOfType(type: 'measures' | 'dimensions' | 'segments', path: string | string[]): boolean {
    const cubeAndName = Array.isArray(path) ? path : path.split('.');
    const symbol = this.evaluatedCubes[cubeAndName[0]]?.[type]?.[cubeAndName[1]];
    return symbol !== undefined;
  }

  public byPathAnyType(path: string | string[]) {
    if (this.isInstanceOfType('measures', path)) {
      return this.byPath('measures', path);
    }

    if (this.isInstanceOfType('dimensions', path)) {
      return this.byPath('dimensions', path);
    }

View on GitHub (pinned to 7d981676b3)

Solutions

  1. Correct the cube name in the path to match the schema declaration exactly
  2. Ensure the schema containing the cube compiles and is loaded into the evaluator
  3. Check for casing/tenant-specific schema loading issues

Example fix

// before
evaluator.cubeNameFromPath('Oders.totalAmount');
// after
evaluator.cubeNameFromPath('Orders.totalAmount');
Defensive patterns

Strategy: validation

Validate before calling

const cubeName = path.split('.')[0];
if (!evaluator.cubeNames().includes(cubeName)) throw new Error(`Unknown cube '${cubeName}' in path '${path}'`);

Try / catch

try { return evaluator.cubeNameFromPath(path); } catch (e) { if (e.message.includes("not found for path")) { /* show available cubes */ } throw e; }

Prevention

When it happens

Trigger: Calling cubeNameFromPath('Oders.totalAmount') or byPath/memberFromPath with a path whose first segment doesn't match any evaluated cube.

Common situations: Misspelled cube names in queries; querying a cube that failed to compile; referring to a view/cube from a different tenant/schema that wasn't loaded; case mismatch.

Related errors


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