cube-js/cube · error
Undefined dbType or dialectClass for '${cube}'
Error message
Undefined dbType or dialectClass for '${cube}' What it means
The cube name exists in the factory map but maps to a falsy QueryClass (undefined). This happens when the cube's dbType is missing/unknown and no dialectClass was provided, so the factory registered a null mapping and cannot instantiate a query.
Source
Thrown at packages/cubejs-schema-compiler/src/adapter/QueryFactory.ts:13
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
- Set a valid dbType for the cube in your data model (one supported by ADAPTERS)
- Pass queryOptions.dialectClass with a custom query class if using a custom dialect
- Check driver registration / imports so the adapter for the dbType is available
Example fix
// before
cube('Events', { sql: ..., /* dbType missing or unsupported */ });
// after
cube('Events', { sql: ..., dataSource: 'default' }); // with driver/dbType registered, or pass dialectClass Defensive patterns
Strategy: validation
Validate before calling
if (cube in cubeToQueryClass && !cubeToQueryClass[cube]) throw new Error(`Cube '${cube}' has no resolvable dbType/dialect; set dbType or dialectClass`); Try / catch
try { return factory.createQuery(cube, compilers, options); } catch (e) { if (/Undefined dbType or dialectClass/.test(e.message)) { /* prompt for dialectClass or fix dbType */ } throw e; } Prevention
- Always declare dataSource/dbType explicitly in cube definitions
- Register custom dialects before schema compilation
- Include a smoke test compiling every cube
When it happens
Trigger: createQuery(cube, ...) where the cube was registered with an undefined query class — typically because the cube's dataSource/dbType is not recognized by ADAPTERS and queryOptions.dialectClass was not supplied.
Common situations: Schema cube declares an unsupported or misspelled sql/dbType; custom dialect expected via dialectClass but not passed in compiler options; driver package not registered before compiling.
Related errors
- Unknown dbType: ${dbType}
- Dialect for '${queryOptions.externalDbType}' is not found
- Can't find dialect for '${dataSource}' data source: ${_dbTyp
- A user-defined contextToApiScopes function returns an incons
- A user-defined contextToApiScopes function returns a wrong s
AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02).
Data as JSON: /api/errors/fbc68ffc0f948aef.
Report an issue: GitHub.