medusajs/medusa · error · MedusaError
ProviderIdentity with entity_id "${entity_id}" not found
Error message
ProviderIdentity with entity_id "${entity_id}" not found What it means
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.
Source
Thrown at packages/modules/auth/src/services/auth-module.ts:1186
throw new MedusaError(
MedusaError.Types.NOT_FOUND,
`AuthIdentity with entity_id "${entity_id}" not found`
)
}
if (authIdentities.length > 1) {
throw new MedusaError(
MedusaError.Types.INVALID_DATA,
`Multiple authIdentities found for entity_id "${entity_id}"`
)
}
const providerIdentityData = authIdentities[0].provider_identities.find(
(pi) => pi.provider === provider
)
if (!providerIdentityData) {
throw new MedusaError(
MedusaError.Types.NOT_FOUND,
`ProviderIdentity with entity_id "${entity_id}" not found`
)
}
const updatedProviderIdentity =
await this.providerIdentityService_.update({
id: providerIdentityData.id,
...data,
})
const serializedResponse =
await this.baseRepository_.serialize<AuthTypes.AuthIdentityDTO>(
authIdentities[0]
)
const serializedProviderIdentity =
await this.baseRepository_.serialize<AuthTypes.ProviderIdentityDTO>(
updatedProviderIdentityView on GitHub (pinned to 5e06e544a2)
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
Example fix
// before
await authModule.updateProviderIdentityByEntityId(entityId, 'emailpass', data)
// after
const [identity] = await authModule.listAuthIdentities({ entity_id: entityId })
const has = identity.provider_identities.some((p) => p.provider === 'emailpass')
if (!has) throw new Error('No emailpass provider identity; link it first')
await authModule.updateProviderIdentityByEntityId(entityId, 'emailpass', data) Defensive patterns
Strategy: validation
Validate before calling
const [identity] = await authModule.listAuthIdentities({ entity_id: entityId })
if (!identity.provider_identities?.some((p) => p.provider === provider)) throw new Error('Provider identity missing') Type guard
const hasProvider = (identity: AuthIdentityDTO, provider: string): boolean => (identity.provider_identities ?? []).some((p) => p.provider === provider)
Try / catch
null
Prevention
- Check linked providers before updating a provider identity
- Link the provider identity first when needed
When it happens
Trigger: User signed up with provider 'google' but the update targets 'emailpass'; provider string typo; provider identity was unlinked/deleted earlier.
Common situations: SSO-only accounts being updated as if they had password credentials; provider naming inconsistencies between systems; flows assuming every identity has every provider.
Related errors
- User ID not found
- User with id: ${id} was not found
- Provider identity with entity_id ${data.entity_id} and provi
- AuthIdentity with entity_id "${entity_id}" not found
- --config file must be of type .json or .yaml - ${configFileC
AI-assisted analysis of medusajs/medusa@5e06e544a2 (2026-08-27).
Data as JSON: /api/errors/bf34438edbdc6646.
Report an issue: GitHub.