{"record":{"id":"47676412c6633552","repo":"mastra-ai/mastra","slug":"okta-domain-is-required-provide-it-in-the-options","errorCode":null,"errorMessage":"Okta domain is required. Provide it in the options or set OKTA_DOMAIN environment variable.","messagePattern":"Okta domain is required\\. Provide it in the options or set OKTA_DOMAIN environment variable\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"auth/okta/src/auth-provider.ts","lineNumber":153,"sourceCode":"  protected cookieMaxAge: number;\n  protected cookiePassword: string;\n  protected secureCookies: boolean;\n  protected apiToken?: string;\n  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      );","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/auth/okta/src/auth-provider.ts#L135-L171","documentation":"Validation thrown in the OktaAuthProvider constructor when no Okta domain was provided via options.domain or the OKTA_DOMAIN environment variable. The domain is required to build issuer/token/authorize endpoints, so the provider cannot be constructed without it.","triggerScenarios":"Instantiating the Okta auth provider (new OktaAuthProvider(...)) with options lacking `domain` while OKTA_DOMAIN is unset in the process environment.","commonSituations":"See trigger scenarios.","solutions":["Set the OKTA_DOMAIN environment variable (e.g. https://dev-123456.okta.com).","Pass `domain` explicitly in the provider options object.","Verify the .env file is loaded (dotenv/platform config) in the runtime environment.","Check for typos in the env var name in both code and deployment config."],"exampleFix":"// before\nconst auth = new OktaAuthProvider({ clientId: 'abc', clientSecret: 'xyz' });\n// after\nconst auth = new OktaAuthProvider({\n  domain: process.env.OKTA_DOMAIN, // set OKTA_DOMAIN=https://dev-123456.okta.com\n  clientId: 'abc',\n  clientSecret: 'xyz',\n});","handlingStrategy":"validation","validationCode":"if (!process.env.OKTA_DOMAIN) {\n  throw new Error('Set OKTA_DOMAIN 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('Okta domain is required')) {\n    throw new Error('Server misconfiguration: OKTA_DOMAIN missing');\n  }\n  throw e;\n}","preventionTips":["Validate required env vars at process startup (fail fast before serving requests).","Keep a .env.example listing OKTA_DOMAIN and audit deploy configs against it.","Beware platform env-var naming limits and typos (OKTA_DOMAIN vs OKTA_ISSUER)."],"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"}