cube-js/cube · error
CUBEJS_DB_NAME can`t be empty.
Error message
CUBEJS_DB_NAME can`t be empty.
What it means
DremioDriver.tablesSchema() requires a database name to introspect tables. Before querying Dremio for the table schema it checks this.config.database, which is populated from the CUBEJS_DB_NAME environment variable, and throws this error when it is empty or undefined. Introspection cannot proceed without knowing which Dremio database (source) to inspect.
Source
Thrown at packages/cubejs-dremio-driver/driver/DremioDriver.js:261
}
async refreshTablesSchema(path) {
const { data } = await this.restDremioQuery('get', `/catalog/by-path/${path}`);
if (!data || !data.children) {
return true;
}
const queries = data.children.map(element => {
const url = element.path.join('/');
return this.refreshTablesSchema(url);
});
return Promise.all(queries);
}
async tablesSchema() {
if (!this.config.database) {
throw new Error('CUBEJS_DB_NAME can`t be empty.');
}
// By some reason query generated by super.tablesSchema will return only tables that we usd before
// So, function refreshTablesSchema used for get all tables by rest api.
// After this, query generated by super.tablesSchema will return all table`s.
await this.refreshTablesSchema(this.config.database);
return super.tablesSchema();
}
informationSchemaQuery() {
const q = `${super.informationSchemaQuery()} AND columns.table_schema NOT IN ('INFORMATION_SCHEMA', 'sys.cache')`;
console.log(q);
return q;
}
}
module.exports = DremioDriver;
module.exports.applyParams = applyParams;View on GitHub (pinned to 7d981676b3)
Solutions
- Set CUBEJS_DB_NAME in your environment to the Dremio database/source name to introspect.
- Alternatively pass `database: '<name>'` explicitly in the driver configuration object.
- Verify with a preflight check in your cube.js bootstrap that process.env.CUBEJS_DB_NAME is non-empty when dbType is dremio.
Example fix
// before (.env) CUBEJS_DB_HOST=dremio.example.com CUBEJS_DB_USER=admin # CUBEJS_DB_NAME missing // after CUBEJS_DB_HOST=dremio.example.com CUBEJS_DB_USER=admin CUBEJS_DB_NAME=my_dremio_source
Defensive patterns
Strategy: validation
Validate before calling
if (!process.env.CUBEJS_DB_NAME) {
throw new Error('Set CUBEJS_DB_NAME before starting the Dremio driver');
} Type guard
function hasDatabase(cfg) {
return typeof cfg?.database === 'string' && cfg.database.length > 0;
} Try / catch
try {
await driver.tablesSchema();
} catch (e) {
if (e.message.includes('CUBEJS_DB_NAME')) {
// fix config and retry
} else throw e;
} Prevention
- Add a startup config check that fails fast when CUBEJS_DB_NAME is missing for Dremio datasources
- Keep all driver env vars in a validated config schema (e.g. with zod/joi)
- Document required Dremio env vars in deployment manifests/secrets
When it happens
Trigger: Calling driver.tablesSchema() (directly or via Cube Store schema introspection) when the driver config was created without a `database` field — typically because CUBEJS_DB_NAME was not set in the environment or the data source config.
Common situations: Deploying Cube for Dremio with an incomplete .env file; forgetting to configure CUBEJS_DB_NAME while only setting host/port/user credentials; renaming config keys and dropping `database` from the driver options.
Understand the failure class
Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.
Related errors
- Please specify CUBEJS_DB_URL
- Unexpected return type, driverFactory must return driver (da
- unknown env variable {}
- 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/8cf34c1fbd32cb56.
Report an issue: GitHub.