cube-js/cube · error · Error

url is required property

Error message

url is required property

What it means

JDBCDriver's constructor requires a JDBC connection URL after checking drivername; it throws 'url is required property' when config.url is empty. The url normally comes from config.url, the CUBEJS_DB_JDBC_URL env var, or a dbType mapping (dbTypeDescription.jdbcUrl()).

Source

Thrown at packages/cubejs-jdbc-driver/src/JDBCDriver.ts:137

    this.config = {
      dbType: getEnv('dbType', { dataSource, preAggregations }),
      url:
        getEnv('jdbcUrl', { dataSource, preAggregations }) ||
        dbTypeDescription && dbTypeDescription.jdbcUrl(),
      drivername:
        getEnv('jdbcDriver', { dataSource, preAggregations }) ||
        dbTypeDescription && dbTypeDescription.driverClass,
      properties: dbTypeDescription && dbTypeDescription.properties,
      ...dbOptions
    } as JDBCDriverConfiguration;

    if (!this.config.drivername) {
      throw new Error('drivername is required property');
    }

    if (!this.config.url) {
      throw new Error('url is required property');
    }

    const poolName = createPoolName('jdbc', dataSource, preAggregations);
    this.pool = new Pool(poolName, {
      create: async () => {
        await initMvn(await this.getCustomClassPath());

        if (!this.jdbcProps) {
          /** @protected */
          this.jdbcProps = this.getJdbcProperties();
        }

        const getConnection = promisify(DriverManager.getConnection.bind(DriverManager));
        return new Connection(await getConnection(this.config.url, this.jdbcProps));
      },
      destroy: async (connection) => promisify(connection.close.bind(connection))(),
      validate: async (connection) => (
        new Promise((resolve) => {

View on GitHub (pinned to 7d981676b3)

Solutions

  1. Pass `url` explicitly, e.g. url: 'jdbc:postgresql://host:5432/db'
  2. Or set CUBEJS_DB_JDBC_URL in the environment
  3. If relying on dbType, verify the mapping generates a JDBC URL and that required fields (host, database) are provided
  4. Check the config key is `url` (or `jdbcURL` alias) and that the env var isn't empty string

Example fix

// before
new JDBCDriver({ drivername: 'org.postgresql.Driver' });
// after
new JDBCDriver({ drivername: 'org.postgresql.Driver', url: 'jdbc:postgresql://localhost:5432/mydb' });
Defensive patterns

Strategy: validation

Validate before calling

function assertJdbcUrl(cfg) {
  if (!cfg.url && !process.env.CUBEJS_DB_JDBC_URL) {
    throw new Error('JDBCDriver requires `url` (jdbc:...) or CUBEJS_DB_JDBC_URL env');
  }
  const url = cfg.url || process.env.CUBEJS_DB_JDBC_URL;
  if (!/^jdbc:[a-z0-9]+:\/\//i.test(url)) {
    throw new Error(`Suspicious JDBC url: ${url}`);
  }
  return cfg;
}

Type guard

function hasJdbcUrl(cfg) {
  return typeof cfg === 'object' && cfg !== null &&
    typeof cfg.url === 'string' && cfg.url.startsWith('jdbc:');
}

Try / catch

try {
  driver = new JDBCDriver(options);
} catch (e) {
  if (e.message === 'url is required property') {
    throw new Error('JDBC config is missing `url`; set url or CUBEJS_DB_JDBC_URL (note the key is `url`, not `jdbcUrl`)');
  }
  throw e;
}

Prevention

When it happens

Trigger: new JDBCDriver({...}) with no `url` and no CUBEJS_DB_JDBC_URL env, and either no dbType or a dbType mapping that does not produce a jdbcUrl (e.g. missing other required fields); or url explicitly set to empty string.

Common situations: Forgetting CUBEJS_DB_JDBC_URL in cube.js env config; passing `jdbcUrl` instead of `url` in the driver config; dbType given but its URL template requires parts (host/port/db) that are missing; empty-string env var overriding defaults via ...dbOptions spread.

Related errors


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