cube-js/cube · error
Undefined cube '${cube}'
Error message
Undefined cube '${cube}' What it means
QueryFactory.createQuery is keyed by cube name; it throws when the requested cube has no mapping in cubeToQueryClass. This means the cube name passed doesn't match any cube registered in the factory (built from the compiled schema's dbType/dialect mapping).
Source
Thrown at packages/cubejs-schema-compiler/src/adapter/QueryFactory.ts:9
export class QueryFactory {
public constructor(
private cubeToQueryClass: Record<string, any>,
) {
}
public createQuery(cube: string, compilers: any, queryOptions: any) {
if (!(cube in this.cubeToQueryClass)) {
throw new Error(`Undefined cube '${cube}'`);
}
const QueryClass = this.cubeToQueryClass[cube];
if (!QueryClass) {
throw new Error(`Undefined dbType or dialectClass for '${cube}'`);
}
return new QueryClass(compilers, queryOptions);
}
}
View on GitHub (pinned to 7d981676b3)
Solutions
- Check the exact cube name against your schema files (name matches the cube/view declaration)
- Recompile/reload the schema to ensure the cube exists and compiled successfully
- Verify the cube's dbType/dialect is defined so the factory registers a mapping for it
Example fix
// before
factory.createQuery('Orders ', compilers, options);
// after
factory.createQuery('Orders', compilers, options); Defensive patterns
Strategy: validation
Validate before calling
const compilerApi = await prepareCompiler({ schemaPath });
const cubes = Object.keys(compilerApi.cubeEvaluator.cubeNames());
if (!cubes.includes(cube)) throw new Error(`Cube ${cube} not in schema; known: ${cubes.join(',')}`); Try / catch
try { return factory.createQuery(cube, compilers, options); } catch (e) { if (e.message.startsWith('Undefined cube')) { /* surface list of valid cubes */ } throw e; } Prevention
- Use compiler-generated cube lists instead of hardcoded strings
- Fail fast at config load when a referenced cube is missing
- Watch for renames in schema files via linting
When it happens
Trigger: Calling queryFactory.createQuery(cube, compilers, queryOptions) with a cube string not present as a key in cubeToQueryClass — e.g. a misspelled cube name or a cube absent from the compiled schema.
Common situations: Typo in the cube name when creating a query programmatically; querying a cube that failed to compile or was renamed; using a cube name with different casing.
Related errors
- Can't resolve ${tableName}: '${schema}' does not exist
- Can't resolve ${tableName}: '${table}' does not exist
- A user-defined contextToApiScopes function returns an incons
- A user-defined contextToApiScopes function returns a wrong s
- Unload is not configured. Please define CUBEJS_AWS_S3_OUTPUT
AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02).
Data as JSON: /api/errors/cc6b605136a9efac.
Report an issue: GitHub.