medusajs/medusa · error · MedusaError
AuthIdentity with entity_id "${entity_id}" not found
Error message
AuthIdentity with entity_id "${entity_id}" not found What it means
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.
Source
Thrown at packages/modules/auth/src/services/auth-module.ts:1106
getAuthIdentityProviderService(
provider: string
): AuthIdentityProviderService {
return {
retrieve: async ({ entity_id }) => {
const authIdentities = await this.authIdentityService_.list(
{
provider_identities: {
entity_id,
provider,
},
},
{
relations: ["provider_identities"],
}
)
if (!authIdentities.length) {
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}"`
)
}
return await this.baseRepository_.serialize<AuthTypes.AuthIdentityDTO>(
authIdentities[0]
)
},
create: async (data: {View on GitHub (pinned to 5e06e544a2)
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
Example fix
// before
await authModule.updateAuthIdentityByEntityId(entityId, update)
// after
const [identity] = await authModule.listAuthIdentities({ entity_id: entityId })
if (!identity) throw new Error(`No auth identity for ${entityId}`)
await authModule.updateAuthIdentityByEntityId(entityId, update) Defensive patterns
Strategy: validation
Validate before calling
const [identity] = await authModule.listAuthIdentities({ entity_id: entityId })
if (!identity) throw new Error('Account not found') Type guard
null
Try / catch
try { await update(entityId) } catch (e) { if (e.type === 'not_found') handleMissingAccount(); throw e } Prevention
- Check identity existence before entity_id-based updates
- Order provisioning before updates
When it happens
Trigger: 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.
Common situations: Sync scripts referencing removed users; cascade deletes of auth identities; mismatch between user records and auth identities after partial migrations.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- User ID not found
- User with id: ${id} was not found
- Provider identity with entity_id ${data.entity_id} and provi
- Multiple authIdentities found for entity_id "${entity_id}"
- ProviderIdentity with entity_id "${entity_id}" not found
AI-assisted analysis of medusajs/medusa@5e06e544a2 (2026-08-27).
Data as JSON: /api/errors/64a341d64d00d165.
Report an issue: GitHub.