{"id":"2def4edc94f53eca","repo":"mongodb/node-mongodb-native","slug":"attempted-to-get-idp-information-when-none-exists","errorCode":null,"errorMessage":"Attempted to get IDP information when none exists.","messagePattern":"Attempted to get IDP information when none exists\\.","errorType":"exception","errorClass":"MongoOIDCError","httpStatus":null,"severity":"error","filePath":"src/cmap/auth/mongodb_oidc/token_cache.ts","lineNumber":41,"sourceCode":"  }\n\n  getAccessToken(): string {\n    if (!this.accessToken) {\n      throw new MongoOIDCError('Attempted to get an access token when none exists.');\n    }\n    return this.accessToken;\n  }\n\n  getRefreshToken(): string {\n    if (!this.refreshToken) {\n      throw new MongoOIDCError('Attempted to get a refresh token when none exists.');\n    }\n    return this.refreshToken;\n  }\n\n  getIdpInfo(): IdPInfo {\n    if (!this.idpInfo) {\n      throw new MongoOIDCError('Attempted to get IDP information when none exists.');\n    }\n    return this.idpInfo;\n  }\n\n  put(response: OIDCResponse, idpInfo?: IdPInfo) {\n    this.accessToken = response.accessToken;\n    this.refreshToken = response.refreshToken;\n    this.expiresInSeconds = response.expiresInSeconds;\n    if (idpInfo) {\n      this.idpInfo = idpInfo;\n    }\n  }\n\n  removeAccessToken() {\n    this.accessToken = undefined;\n  }\n\n  removeRefreshToken() {","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/mongodb/node-mongodb-native/blob/3366c21a6311e02f1be91da982f9b93d3cce99a0/src/cmap/auth/mongodb_oidc/token_cache.ts#L23-L59","documentation":"Thrown by the OIDC TokenCache.getIdpInfo() when no IdP (Identity Provider) information is cached (src/cmap/auth/mongodb_oidc/token_cache.ts:40). Internal invariant: callers must check hasIdpInfo before invoking getIdpInfo. Surfaced as a MongoDriverError (local MongoOIDCError subclass), reflecting a workflow state-machine bug rather than a user configuration problem.","triggerScenarios":"Internal: a workflow path calls cache.getIdpInfo() before the IdP info has been populated by a successful Two-Step SASL conversation. Not reachable through normal public API usage.","commonSituations":"Not user-triggered in normal operation. Could appear after a driver regression in the human workflow reauthenticate path.","solutions":["Upgrade to the latest driver patch release.","If reproducible, file a driver bug with the OIDC environment and steps.","As a workaround, recreate the MongoClient to reset cache state.","Ensure you are not using an internal/experimental OIDC API surface."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await client.connect();\n} catch (e) {\n  if (e instanceof MongoDriverError && /get IDP information when none exists/.test(e.message)) {\n    client.close();\n    throw new Error('Driver OIDC cache invariant violated - please file a bug.');\n  }\n  throw e;\n}","preventionTips":["Upgrade the driver regularly.","Recreate the MongoClient on persistent auth errors.","Do not use internal OIDC workflow APIs directly."],"tags":["auth","oidc","internal","invariant","token-cache"],"analyzedSha":"3366c21a6311e02f1be91da982f9b93d3cce99a0","analyzedAt":"2026-08-04T13:40:15.335Z","schemaVersion":2}