cube-js/cube · error · Error
CreateOptions.dbType was removed in v1.7.0. Use driverFactor
Error message
CreateOptions.dbType was removed in v1.7.0. Use driverFactory instead (return a DriverConfig `{ type, ... }`), or set the CUBEJS_DB_TYPE environment variable. See https://github.com/cube-js/cube/blob/master/DEPRECATION.md#dbtype What it means
sanitizeOptions (invoked from OptsHandler's constructor via options()) rejects the legacy CreateOptions.dbType option, which was removed in Cube v1.7.0. Passing dbType now aborts startup immediately with a deprecation error directing users to driverFactory or the CUBEJS_DB_TYPE env variable. This is an intentional hard break to migrate from the old option API.
Source
Thrown at packages/cubejs-server-core/src/core/OptsHandler.ts:65
this.initializedOptions = this.initializeCoreOptions(options);
}
private decoratedFactory = false;
public isCustomDriverFactory(): boolean {
return !this.decoratedFactory;
}
/**
* driverFactory function result type.
*/
private driverFactoryType: undefined | 'BaseDriver' | 'DriverConfig';
private initializedOptions: ServerCoreInitializedOptions;
private sanitizeOptions<T extends CreateOptions>(opts: T): T {
if ((opts as any).dbType) {
throw new Error(
'CreateOptions.dbType was removed in v1.7.0. ' +
'Use driverFactory instead (return a DriverConfig `{ type, ... }`), ' +
'or set the CUBEJS_DB_TYPE environment variable. ' +
'See https://github.com/cube-js/cube/blob/master/DEPRECATION.md#dbtype'
);
}
const validated = validateOptions(opts);
// Probed for its throw: the only consumer is per-request code (normalizeQuery)
getEnv('defaultTimezone');
if (
!this.isDevMode() &&
!process.env.CUBEJS_DB_TYPE &&
!opts.driverFactory
) {
throw new Error(View on GitHub (pinned to 7d981676b3)
Solutions
- Remove dbType from CreateOptions
- Move the db type into the driverFactory return value: driverFactory: async () => ({ type: 'postgres' })
- Or set the CUBEJS_DB_TYPE environment variable instead
- Consult the DEPRECATION.md#dbtype section linked in the error
Example fix
// before
create({ dbType: 'postgres', dbFactory: () => ({ host: 'localhost' }) })
// after
create({ driverFactory: async () => ({ type: 'postgres', host: 'localhost' }) }) Defensive patterns
Strategy: validation
Validate before calling
function assertNoLegacyDbType(options) {
if ('dbType' in options) {
throw new Error('dbType was removed in v1.7.0: use driverFactory ({ type, ... }) or CUBEJS_DB_TYPE');
}
}
assertNoDbType(myCreateOptions); Type guard
function usesModernDriverOptions(opts) {
return !('dbType' in opts) && (typeof opts.driverFactory === 'function' || !!process.env.CUBEJS_DB_TYPE);
} Try / catch
try {
const server = await create(opts);
} catch (e) {
if (e.message.includes('CreateOptions.dbType was removed')) {
// migrate: move dbType into driverFactory return or CUBEJS_DB_TYPE
}
throw e;
} Prevention
- Remove dbType from all create() calls when upgrading to v1.7.0+
- Follow DEPRECATION.md#dbtype migration steps before upgrading
- Search the codebase and scaffolding scripts for `dbType:` in CreateOptions
- Prefer driverFactory returning a DriverConfig as the modern pattern
When it happens
Trigger: Calling cubejs-server-core's create/initialization with `dbType` in the CreateOptions object after upgrading to v1.7.0+, e.g. create({ dbType: 'postgres', ... }).
Common situations: Upgrading a project from pre-1.7 Cube following old tutorials/docs; copy-pasted bootstrap code; scaffolding tools that still emit dbType.
Related errors
- Unsupported db type: ${dbType}
- Either CUBEJS_DB_TYPE or CreateOptions.driverFactory must be
- The ${keyByDataSource('CUBEJS_DB_SCHEMA', dataSource)} is de
- The ${keyByDataSource('CUBEJS_DATABASE', dataSource)} is dep
- The CUBEJS_DB_CATALOG is deprecated. Please, use the CUBEJS_
AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02).
Data as JSON: /api/errors/1ad9eee3fd62b993.
Report an issue: GitHub.