cube-js/cube · error

${invalidFields.join(', ')} ${invalidFields.length === 1 ? '

Error message

${invalidFields.join(', ')} ${invalidFields.length === 1 ? 'is' : 'are'} required option(s)

What it means

initializeCoreOptions validates that required CreateOptions fields are present, collecting any that are undefined and throwing a message listing them ('X is/are required option(s)'). Typical required fields include apiSecret (and others such as devServerSecret-derived fields in relevant modes). The constructor runs this right after sanitizeOptions, so misconfigured create() calls fail at startup.

Source

Thrown at packages/cubejs-server-core/src/core/OptsHandler.ts:467

        }`
      );
    }

    if (!options.devServer || this.configuredForQueryProcessing()) {
      const fieldsForValidation: (keyof ServerCoreInitializedOptions)[] = [
        'driverFactory',
        'dbType'
      ];

      if (!options.jwt?.jwkUrl) {
        // apiSecret is required only for auth by JWT, for JWK it's not needed
        fieldsForValidation.push('apiSecret');
      }

      const invalidFields =
        fieldsForValidation.filter((field) => options[field] === undefined);
      if (invalidFields.length) {
        throw new Error(
          `${
            invalidFields.join(', ')
          } ${
            invalidFields.length === 1 ? 'is' : 'are'
          } required option(s)`
        );
      }
    }

    return options;
  }

  /**
   * Determines whether current instance should be bootstraped in the
   * dev mode or not.
   */
  private isDevMode(): boolean {
    return (

View on GitHub (pinned to 7d981676b3)

Solutions

  1. Pass the listed option(s) to create(), e.g. apiSecret: '<secret>'
  2. Or set the corresponding env variable (e.g. CUBEJS_API_SECRET)
  3. Check the error message for the exact field names listed and fix spelling
  4. Verify the options object isn't losing values (bad dotenv loading, wrong config file)

Example fix

// before
create({ }) // apiSecret missing in prod
// after
create({ apiSecret: process.env.CUBEJS_API_SECRET })
// with CUBEJS_API_SECRET set in the environment
Defensive patterns

Strategy: validation

Validate before calling

function assertRequiredCreateOptions(options, required = ['apiSecret']) {
  const missing = required.filter(f => options[f] === undefined);
  if (missing.length) {
    throw new Error(`${missing.join(', ')} ${missing.length === 1 ? 'is' : 'are'} required option(s)`);
  }
}
assertRequiredCreateOptions(createOptions);

Type guard

function hasRequiredOptions(opts, keys) {
  return keys.every(k => opts[k] !== undefined);
}

Try / catch

try {
  await create(opts);
} catch (e) {
  if (/required option\(s\)$/.test(e.message)) {
    const missing = e.message.split(' ')[0].split(', ');
    console.error('Missing create() options:', missing, '— set them or the matching env vars.');
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling create()/new CubejsServerCore without apiSecret in production mode (apiSecret is added to fieldsForValidation when not provided via env elsewhere and is undefined), or omitting other fields pushed to fieldsForValidation based on the current mode/env.

Common situations: Deploying without CUBEJS_API_SECRET and without options.apiSecret; upgrading where a previously-optional option became required; scaffolding that left placeholder values as undefined; spelling the option key incorrectly (e.g. apiSecret vs api_secret).

Understand the failure class

Background: "Must pass :limit option" / "Missing required option" — required option errors explained — this error's family across 41 libraries.

Related errors


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