{"record":{"id":"a84cbd0734614056","repo":"mastra-ai/mastra","slug":"okta-client-id-is-required-provide-it-in-the-opti","errorCode":null,"errorMessage":"Okta client ID is required. Provide it in the options or set OKTA_CLIENT_ID environment variable.","messagePattern":"Okta client ID is required\\. Provide it in the options or set OKTA_CLIENT_ID environment variable\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"auth/okta/src/auth-provider.ts","lineNumber":157,"sourceCode":"  private jwks: ReturnType<typeof createRemoteJWKSet>;\n\n  constructor(options?: MastraAuthOktaOptions) {\n    super({ name: options?.name ?? 'okta' });\n\n    const domain = options?.domain ?? process.env.OKTA_DOMAIN;\n    const clientId = options?.clientId ?? process.env.OKTA_CLIENT_ID;\n    const clientSecret = options?.clientSecret ?? process.env.OKTA_CLIENT_SECRET;\n    const issuer = options?.issuer ?? process.env.OKTA_ISSUER;\n    const redirectUri = options?.redirectUri ?? process.env.OKTA_REDIRECT_URI;\n    const cookiePassword =\n      options?.session?.cookiePassword ?? process.env.OKTA_COOKIE_PASSWORD ?? crypto.randomUUID() + crypto.randomUUID();\n\n    if (!domain) {\n      throw new Error('Okta domain is required. Provide it in the options or set OKTA_DOMAIN environment variable.');\n    }\n\n    if (!clientId) {\n      throw new Error(\n        'Okta client ID is required. Provide it in the options or set OKTA_CLIENT_ID environment variable.',\n      );\n    }\n\n    if (!clientSecret) {\n      throw new Error(\n        'Okta client secret is required for SSO. Provide it in the options or set OKTA_CLIENT_SECRET environment variable.',\n      );\n    }\n\n    if (!redirectUri) {\n      throw new Error(\n        'Okta redirect URI is required for SSO. Provide it in the options or set OKTA_REDIRECT_URI environment variable.',\n      );\n    }\n\n    if (cookiePassword.length < 32) {\n      throw new Error('Cookie password must be at least 32 characters. Set OKTA_COOKIE_PASSWORD environment variable.');","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/auth/okta/src/auth-provider.ts#L139-L175","documentation":"Validation thrown in the OktaAuthProvider constructor when no client ID was supplied via options or OKTA_CLIENT_ID environment variable. The client ID identifies the OIDC application to Okta and is mandatory for any auth flow.","triggerScenarios":"new OktaAuthProvider(...) with domain set but neither options.clientId nor OKTA_CLIENT_ID defined.","commonSituations":"Env var missing in production after being present locally; OIDC app deleted or ID rotated in the Okta dashboard; secrets manager not injected into the container.","solutions":["Set the OKTA_CLIENT_ID environment variable from the Okta application settings.","Pass `clientId` explicitly in the constructor options.","Confirm the app integration still exists in the Okta admin console and copy its client ID.","Verify the deployment/CI injects the variable into the runtime environment."],"exampleFix":"// before\nnew OktaAuthProvider({ domain: 'https://dev-123.okta.com' });\n// after\nnew OktaAuthProvider({\n  domain: 'https://dev-123.okta.com',\n  clientId: process.env.OKTA_CLIENT_ID, // set in env\n  clientSecret: process.env.OKTA_CLIENT_SECRET,\n});","handlingStrategy":"validation","validationCode":"if (!process.env.OKTA_CLIENT_ID) {\n  throw new Error('Set OKTA_CLIENT_ID before constructing OktaAuthProvider');\n}\nconst auth = new OktaAuthProvider();","typeGuard":null,"tryCatchPattern":"try {\n  auth = new OktaAuthProvider();\n} catch (e) {\n  if (e instanceof Error && e.message.includes('client ID is required')) {\n    throw new Error('Server misconfiguration: OKTA_CLIENT_ID missing');\n  }\n  throw e;\n}","preventionTips":["Store the client ID alongside other Okta settings and check it at startup.","Verify the Okta application still exists after admin changes/cleanups.","Confirm CI/CD injects the variable into the runtime environment, not just build."],"tags":["okta","configuration","env-var","constructor"],"backgroundTag":"missing-env-var","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}