{"id":"fa7bdab88ea17cc8","repo":"mongodb/node-mongodb-native","slug":"could-not-load-workflow-for-environment-authmech","errorCode":null,"errorMessage":"Could not load workflow for environment ${authMechanismProperties.ENVIRONMENT}","messagePattern":"Could not load workflow for environment (.+?)","errorType":"exception","errorClass":"MongoInvalidArgumentError","httpStatus":null,"severity":"error","filePath":"src/mongo_client_auth_providers.ts","lineNumber":81,"sourceCode":"    const provider = providerFunction(authMechanismProperties);\n    this.existingProviders.set(name, provider);\n    return provider;\n  }\n}\n\n/**\n * Gets either a device workflow or callback workflow.\n */\nfunction getWorkflow(authMechanismProperties: AuthMechanismProperties): Workflow {\n  if (authMechanismProperties.OIDC_HUMAN_CALLBACK) {\n    return new HumanCallbackWorkflow(new TokenCache(), authMechanismProperties.OIDC_HUMAN_CALLBACK);\n  } else if (authMechanismProperties.OIDC_CALLBACK) {\n    return new AutomatedCallbackWorkflow(new TokenCache(), authMechanismProperties.OIDC_CALLBACK);\n  } else {\n    const environment = authMechanismProperties.ENVIRONMENT;\n    const workflow = OIDC_WORKFLOWS.get(environment)?.();\n    if (!workflow) {\n      throw new MongoInvalidArgumentError(\n        `Could not load workflow for environment ${authMechanismProperties.ENVIRONMENT}`\n      );\n    }\n    return workflow;\n  }\n}\n","sourceCodeStart":63,"sourceCodeEnd":88,"githubUrl":"https://github.com/mongodb/node-mongodb-native/blob/3366c21a6311e02f1be91da982f9b93d3cce99a0/src/mongo_client_auth_providers.ts#L63-L88","documentation":"Thrown by getWorkflow() when MONGODB-OIDC is used without a callback (OIDC_HUMAN_CALLBACK/OIDC_CALLBACK) and the configured ENVIRONMENT does not map to a known workflow in OIDC_WORKFLOWS. Known environments are aws, gcp, azure, and test. An unrecognized ENVIRONMENT string means the driver cannot pick a token-acquisition strategy. MongoInvalidArgumentError.","triggerScenarios":"Setting authMechanismProperties=ENVIRONMENT:<value> to something other than aws/gcp/azure/test while using MONGODB-OIDC without a callback. Typos like 'AWS' (case) or 'awss'.","commonSituations":"Migrating between cloud providers; typos in ENVIRONMENT; specifying ENVIRONMENT when you actually intend callback-based OIDC.","solutions":["Use one of the supported ENVIRONMENT values: aws, gcp, azure, or test.","If you have a custom token source, provide OIDC_HUMAN_CALLBACK or OIDC_CALLBACK instead of ENVIRONMENT.","Verify the value is lowercase and exactly matches a supported environment."],"exampleFix":"// before\nconst uri = 'mongodb://u@h/?authMechanism=MONGODB-OIDC&authMechanismProperties=ENVIRONMENT:awss';\n\n// after\nconst uri = 'mongodb://u@h/?authMechanism=MONGODB-OIDC&authMechanismProperties=ENVIRONMENT:aws';","handlingStrategy":"validation","validationCode":"const OIDC_ENVS = new Set(['aws','gcp','azure','test']);\nif (env && !OIDC_ENVS.has(env)) throw new Error('Unknown OIDC ENVIRONMENT');","typeGuard":"function isKnownOidcEnv(v): v is 'aws'|'gcp'|'azure'|'test' {\n  return ['aws','gcp','azure','test'].includes(v);\n}","tryCatchPattern":null,"preventionTips":["Use lowercase ENVIRONMENT values","Provide a callback for custom OIDC flows","Validate ENVIRONMENT at config load time"],"tags":["oidc","auth","environment","configuration"],"analyzedSha":"3366c21a6311e02f1be91da982f9b93d3cce99a0","analyzedAt":"2026-08-04T13:40:15.335Z","schemaVersion":2}