{"record":{"id":"eeeab95fd48b75c1","repo":"medusajs/medusa","slug":"mfa-factor-with-id-id-was-not-found","errorCode":null,"errorMessage":"MFA factor with id \"${id}\" was not found","messagePattern":"MFA factor with id \"(.+?)\" was not found","errorType":"exception","errorClass":"MedusaError","httpStatus":404,"severity":"error","filePath":"packages/modules/auth/src/services/auth-module.ts","lineNumber":591,"sourceCode":"  ): Promise<AuthTypes.AuthMfaDTO> {\n    const filters =\n      typeof selector === \"string\"\n        ? { id: [selector] }\n        : {\n            id: [selector.id],\n            auth_identity_id: selector.auth_identity_id,\n          }\n\n    const [factor] = await this.authMfaFactorService_.list(\n      filters,\n      config,\n      sharedContext\n    )\n\n    if (!factor) {\n      const id = typeof selector === \"string\" ? selector : selector.id\n\n      throw new MedusaError(\n        MedusaError.Types.NOT_FOUND,\n        `MFA factor with id \"${id}\" was not found`\n      )\n    }\n\n    return await this.serializeMfaFactor_(factor)\n  }\n\n  @InjectManager()\n  async listAuthMfa(\n    filters: AuthTypes.FilterableAuthMfaProps = {},\n    config: FindConfig<AuthTypes.AuthMfaDTO> = {},\n    @MedusaContext() sharedContext: Context = {}\n  ): Promise<AuthTypes.AuthMfaDTO[]> {\n    const factors = await this.authMfaFactorService_.list(\n      filters,\n      config,\n      sharedContext","sourceCodeStart":573,"sourceCodeEnd":609,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/modules/auth/src/services/auth-module.ts#L573-L609","documentation":"Thrown by AuthModuleService.retrieveAuthMfa when no MFA factor matches the given selector (id string or selector object). It is a NOT_FOUND MedusaError, meaning the caller referenced an MFA factor that does not exist (or was already deleted) in the auth module.","triggerScenarios":"Calling authModuleService.retrieveAuthMfa('mfactor_123') or with a selector object whose id does not exist; calling after the factor was removed via removeAuthMfaFactor; passing an id belonging to a different auth identity.","commonSituations":"Stale factor id persisted in client/UI state after re-registering MFA; deleting and recreating factors during testing; race where another session removed the factor.","solutions":["Verify the factor id exists first with listAuthMfaFactors({ auth_identity_id }) before retrieving","Catch MedusaError with type NOT_FOUND and prompt the user to re-enroll MFA","Ensure you are not reusing ids from a previous database/seed"],"exampleFix":"// before\nconst factor = await authModule.retrieveAuthMfa(factorId)\n// after\nconst factors = await authModule.listAuthMfaFactors({ auth_identity_id: identityId })\nconst factor = factors.find((f) => f.id === factorId)\nif (!factor) throw new Error('Factor no longer enrolled; re-enroll MFA')","handlingStrategy":"try-catch","validationCode":"const factors = await authModule.listAuthMfaFactors({ auth_identity_id: identityId })\nconst exists = factors.some((f) => f.id === factorId)\nif (!exists) return reenrollMfa()","typeGuard":"const isMfaFactorId = (id: string): boolean => /^mfactor_/.test(id)","tryCatchPattern":"try { return await authModule.retrieveAuthMfa(factorId) } catch (e) { if (e.type === 'not_found') return reenrollMfa(); throw e }","preventionTips":["List factors for the identity before retrieving by id","Invalidate stored factor ids when factors are removed"],"tags":["mfa","not-found","auth-module"],"backgroundTag":"resource-not-found","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}