{"record":{"id":"74a0eb47bcbd0ece","repo":"cube-js/cube","slug":"invalidfields-join-invalidfields-length","errorCode":null,"errorMessage":"${invalidFields.join(', ')} ${invalidFields.length === 1 ? 'is' : 'are'} required option(s)","messagePattern":"(.+?) (.+?) required option\\(s\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cubejs-server-core/src/core/OptsHandler.ts","lineNumber":467,"sourceCode":"        }`\n      );\n    }\n\n    if (!options.devServer || this.configuredForQueryProcessing()) {\n      const fieldsForValidation: (keyof ServerCoreInitializedOptions)[] = [\n        'driverFactory',\n        'dbType'\n      ];\n\n      if (!options.jwt?.jwkUrl) {\n        // apiSecret is required only for auth by JWT, for JWK it's not needed\n        fieldsForValidation.push('apiSecret');\n      }\n\n      const invalidFields =\n        fieldsForValidation.filter((field) => options[field] === undefined);\n      if (invalidFields.length) {\n        throw new Error(\n          `${\n            invalidFields.join(', ')\n          } ${\n            invalidFields.length === 1 ? 'is' : 'are'\n          } required option(s)`\n        );\n      }\n    }\n\n    return options;\n  }\n\n  /**\n   * Determines whether current instance should be bootstraped in the\n   * dev mode or not.\n   */\n  private isDevMode(): boolean {\n    return (","sourceCodeStart":449,"sourceCodeEnd":485,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-server-core/src/core/OptsHandler.ts#L449-L485","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","solutions":["Pass the listed option(s) to create(), e.g. apiSecret: '<secret>'","Or set the corresponding env variable (e.g. CUBEJS_API_SECRET)","Check the error message for the exact field names listed and fix spelling","Verify the options object isn't losing values (bad dotenv loading, wrong config file)"],"exampleFix":"// before\ncreate({ }) // apiSecret missing in prod\n// after\ncreate({ apiSecret: process.env.CUBEJS_API_SECRET })\n// with CUBEJS_API_SECRET set in the environment","handlingStrategy":"validation","validationCode":"function assertRequiredCreateOptions(options, required = ['apiSecret']) {\n  const missing = required.filter(f => options[f] === undefined);\n  if (missing.length) {\n    throw new Error(`${missing.join(', ')} ${missing.length === 1 ? 'is' : 'are'} required option(s)`);\n  }\n}\nassertRequiredCreateOptions(createOptions);","typeGuard":"function hasRequiredOptions(opts, keys) {\n  return keys.every(k => opts[k] !== undefined);\n}","tryCatchPattern":"try {\n  await create(opts);\n} catch (e) {\n  if (/required option\\(s\\)$/.test(e.message)) {\n    const missing = e.message.split(' ')[0].split(', ');\n    console.error('Missing create() options:', missing, '— set them or the matching env vars.');\n  }\n  throw e;\n}","preventionTips":["Always provide apiSecret (or CUBEJS_API_SECRET) in production deployments","Validate the create options object in CI before deploys","Check dotenv/config loading actually populates the options object","Match option key spelling exactly (camelCase) as documented"],"tags":["config","validation","required-options","api-secret"],"backgroundTag":"missing-required-option","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}