{"record":{"id":"bf34438edbdc6646","repo":"medusajs/medusa","slug":"provideridentity-with-entity-id-entity-id-not","errorCode":null,"errorMessage":"ProviderIdentity with entity_id \"${entity_id}\" not found","messagePattern":"ProviderIdentity with entity_id \"(.+?)\" not found","errorType":"exception","errorClass":"MedusaError","httpStatus":404,"severity":"error","filePath":"packages/modules/auth/src/services/auth-module.ts","lineNumber":1186,"sourceCode":"          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        const providerIdentityData = authIdentities[0].provider_identities.find(\n          (pi) => pi.provider === provider\n        )\n\n        if (!providerIdentityData) {\n          throw new MedusaError(\n            MedusaError.Types.NOT_FOUND,\n            `ProviderIdentity with entity_id \"${entity_id}\" not found`\n          )\n        }\n\n        const updatedProviderIdentity =\n          await this.providerIdentityService_.update({\n            id: providerIdentityData.id,\n            ...data,\n          })\n\n        const serializedResponse =\n          await this.baseRepository_.serialize<AuthTypes.AuthIdentityDTO>(\n            authIdentities[0]\n          )\n        const serializedProviderIdentity =\n          await this.baseRepository_.serialize<AuthTypes.ProviderIdentityDTO>(\n            updatedProviderIdentity","sourceCodeStart":1168,"sourceCodeEnd":1204,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/modules/auth/src/services/auth-module.ts#L1168-L1204","documentation":"NOT_FOUND thrown when the auth identity exists but has no provider identity for the requested provider (the .find on provider_identities returned nothing), during a provider-identity update by entity_id.","triggerScenarios":"User signed up with provider 'google' but the update targets 'emailpass'; provider string typo; provider identity was unlinked/deleted earlier.","commonSituations":"SSO-only accounts being updated as if they had password credentials; provider naming inconsistencies between systems; flows assuming every identity has every provider.","solutions":["Check the identity's provider_identities list and target a provider that actually exists","Create/link the provider identity first if it should exist","Align provider naming across signup and update flows"],"exampleFix":"// before\nawait authModule.updateProviderIdentityByEntityId(entityId, 'emailpass', data)\n// after\nconst [identity] = await authModule.listAuthIdentities({ entity_id: entityId })\nconst has = identity.provider_identities.some((p) => p.provider === 'emailpass')\nif (!has) throw new Error('No emailpass provider identity; link it first')\nawait authModule.updateProviderIdentityByEntityId(entityId, 'emailpass', data)","handlingStrategy":"validation","validationCode":"const [identity] = await authModule.listAuthIdentities({ entity_id: entityId })\nif (!identity.provider_identities?.some((p) => p.provider === provider)) throw new Error('Provider identity missing')","typeGuard":"const hasProvider = (identity: AuthIdentityDTO, provider: string): boolean => (identity.provider_identities ?? []).some((p) => p.provider === provider)","tryCatchPattern":"null","preventionTips":["Check linked providers before updating a provider identity","Link the provider identity first when needed"],"tags":["auth","provider-identity","not-found"],"backgroundTag":"provider-not-linked","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}