{"record":{"id":"64a341d64d00d165","repo":"medusajs/medusa","slug":"authidentity-with-entity-id-entity-id-not-fou","errorCode":null,"errorMessage":"AuthIdentity with entity_id \"${entity_id}\" not found","messagePattern":"AuthIdentity with entity_id \"(.+?)\" not found","errorType":"exception","errorClass":"MedusaError","httpStatus":404,"severity":"error","filePath":"packages/modules/auth/src/services/auth-module.ts","lineNumber":1106,"sourceCode":"  getAuthIdentityProviderService(\n    provider: string\n  ): AuthIdentityProviderService {\n    return {\n      retrieve: async ({ entity_id }) => {\n        const authIdentities = await this.authIdentityService_.list(\n          {\n            provider_identities: {\n              entity_id,\n              provider,\n            },\n          },\n          {\n            relations: [\"provider_identities\"],\n          }\n        )\n\n        if (!authIdentities.length) {\n          throw new MedusaError(\n            MedusaError.Types.NOT_FOUND,\n            `AuthIdentity with entity_id \"${entity_id}\" not found`\n          )\n        }\n\n        if (authIdentities.length > 1) {\n          throw new MedusaError(\n            MedusaError.Types.INVALID_DATA,\n            `Multiple authIdentities found for entity_id \"${entity_id}\"`\n          )\n        }\n\n        return await this.baseRepository_.serialize<AuthTypes.AuthIdentityDTO>(\n          authIdentities[0]\n        )\n      },\n\n      create: async (data: {","sourceCodeStart":1088,"sourceCodeEnd":1124,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/modules/auth/src/services/auth-module.ts#L1088-L1124","documentation":"NOT_FOUND thrown when updating an auth identity by entity_id and zero auth identities match the lookup (queried with provider_identities relation). Means no account exists for that entity_id.","triggerScenarios":"Calling the update-by-entity_id path (e.g. admin-driven identity update) with an entity_id that has no auth identity; entity_id typo; data deleted concurrently.","commonSituations":"Sync scripts referencing removed users; cascade deletes of auth identities; mismatch between user records and auth identities after partial migrations.","solutions":["Confirm the entity_id exists via listAuthIdentities first","If identities were deleted, recreate the auth identity then retry","Guard the operation in a try-catch treating it as a no-op/user-missing case"],"exampleFix":"// before\nawait authModule.updateAuthIdentityByEntityId(entityId, update)\n// after\nconst [identity] = await authModule.listAuthIdentities({ entity_id: entityId })\nif (!identity) throw new Error(`No auth identity for ${entityId}`)\nawait authModule.updateAuthIdentityByEntityId(entityId, update)","handlingStrategy":"validation","validationCode":"const [identity] = await authModule.listAuthIdentities({ entity_id: entityId })\nif (!identity) throw new Error('Account not found')","typeGuard":"null","tryCatchPattern":"try { await update(entityId) } catch (e) { if (e.type === 'not_found') handleMissingAccount(); throw e }","preventionTips":["Check identity existence before entity_id-based updates","Order provisioning before updates"],"tags":["auth","identity","not-found"],"backgroundTag":"resource-not-found","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}