{"id":"25287c78df073729","repo":"mongodb/node-mongodb-native","slug":"no-workflow-provided-to-the-oidc-auth-provider","errorCode":null,"errorMessage":"No workflow provided to the OIDC auth provider.","messagePattern":"No workflow provided to the OIDC auth provider\\.","errorType":"exception","errorClass":"MongoInvalidArgumentError","httpStatus":null,"severity":"error","filePath":"src/cmap/auth/mongodb_oidc.ts","lineNumber":141,"sourceCode":"export const OIDC_WORKFLOWS: Map<EnvironmentName, () => Workflow> = new Map();\nOIDC_WORKFLOWS.set('test', () => new AutomatedCallbackWorkflow(new TokenCache(), testCallback));\nOIDC_WORKFLOWS.set('azure', () => new AutomatedCallbackWorkflow(new TokenCache(), azureCallback));\nOIDC_WORKFLOWS.set('gcp', () => new AutomatedCallbackWorkflow(new TokenCache(), gcpCallback));\nOIDC_WORKFLOWS.set('k8s', () => new AutomatedCallbackWorkflow(new TokenCache(), k8sCallback));\n\n/**\n * OIDC auth provider.\n */\nexport class MongoDBOIDC extends AuthProvider {\n  workflow: Workflow;\n\n  /**\n   * Instantiate the auth provider.\n   */\n  constructor(workflow?: Workflow) {\n    super();\n    if (!workflow) {\n      throw new MongoInvalidArgumentError('No workflow provided to the OIDC auth provider.');\n    }\n    this.workflow = workflow;\n  }\n\n  /**\n   * Authenticate using OIDC\n   */\n  override async auth(authContext: AuthContext): Promise<void> {\n    const { connection, reauthenticating, response } = authContext;\n    if (response?.speculativeAuthenticate?.done && !reauthenticating) {\n      return;\n    }\n    const credentials = getCredentials(authContext);\n    if (reauthenticating) {\n      await this.workflow.reauthenticate(connection, credentials);\n    } else {\n      await this.workflow.execute(connection, credentials, response);\n    }","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/mongodb/node-mongodb-native/blob/3366c21a6311e02f1be91da982f9b93d3cce99a0/src/cmap/auth/mongodb_oidc.ts#L123-L159","documentation":"Thrown by the MongoDBOIDC auth provider constructor when no Workflow instance is supplied (src/cmap/auth/mongodb_oidc.ts:140). The provider requires a workflow to know how to obtain tokens. Surfaced as a MongoInvalidArgumentError. In normal operation the driver selects a workflow from OIDC_WORKFLOWS based on ENVIRONMENT; this error indicates the provider was instantiated directly without one.","triggerScenarios":"Internal/programmatic: constructing 'new MongoDBOIDC()' with no argument. Not triggered by standard MongoClient usage, since the driver's auth provider registry always supplies a workflow derived from the configured ENVIRONMENT.","commonSituations":"User code instantiating the internal MongoDBOIDC provider directly (advanced/integration use), or a driver regression where the provider registry fails to map ENVIRONMENT to a workflow factory.","solutions":["Do not construct MongoDBOIDC directly; configure OIDC via MongoClient options and let the driver pick the workflow.","If you must instantiate it, pass a Workflow implementation as the constructor argument.","Ensure ENVIRONMENT is set to one of the supported values (azure/gcp/k8s/test) so the driver can select a workflow."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"function assertOidcEnvironment(env: string | undefined): void {\n  const supported = new Set(['azure', 'gcp', 'k8s', 'test']);\n  if (env && !supported.has(env)) {\n    throw new Error(`Unsupported OIDC ENVIRONMENT '${env}'. Supported: ${[...supported].join(', ')}`);\n  }\n}\nassertOidcEnvironment(parsedMechanismProperties.ENVIRONMENT);","typeGuard":null,"tryCatchPattern":"try {\n  await client.connect();\n} catch (e) {\n  if (e instanceof MongoInvalidArgumentError && /No workflow provided to the OIDC auth provider/.test(e.message)) {\n    throw new Error('OIDC could not select a workflow - set a supported ENVIRONMENT in authMechanismProperties.');\n  }\n  throw e;\n}","preventionTips":["Configure OIDC through MongoClient options rather than instantiating MongoDBOIDC directly.","Always set ENVIRONMENT to a supported value when using MONGODB-OIDC.","Avoid reaching into internal auth provider constructors."],"tags":["auth","oidc","internal","configuration","validation"],"analyzedSha":"3366c21a6311e02f1be91da982f9b93d3cce99a0","analyzedAt":"2026-08-04T13:40:15.335Z","schemaVersion":2}