{"record":{"id":"dc31f0a4b774b79f","repo":"medusajs/medusa","slug":"auth-identity-not-found","errorCode":null,"errorMessage":"Auth identity not found","messagePattern":"Auth identity not found","errorType":"exception","errorClass":"MedusaError","httpStatus":404,"severity":"error","filePath":"packages/core/core-flows/src/customer/workflows/remove-customer-account.ts","lineNumber":43,"sourceCode":"interface GetCustomerAuthIdentityStepInput {\n  authIdentities: {\n    id: string\n    app_metadata?: Record<string, unknown>\n    provider_identities?: { entity_id: string }[]\n  }[]\n}\n\n/**\n * This step returns the customer's auth identity from a queried list. It throws\n * an error if no auth identity is found.\n */\nexport const getCustomerAuthIdentityStep = createStep(\n  \"get-customer-auth-identity\",\n  async ({ authIdentities }: GetCustomerAuthIdentityStepInput) => {\n    const authIdentity = authIdentities[0]\n\n    if (!authIdentity) {\n      throw new MedusaError(\n        MedusaError.Types.NOT_FOUND,\n        \"Auth identity not found\"\n      )\n    }\n\n    return new StepResponse(authIdentity)\n  }\n)\n\nexport const removeCustomerAccountWorkflowId = \"remove-customer-account\"\n/**\n * This workflow deletes a customer and remove its association to its auth identity. It's used by the\n * [Delete Customer Admin API Route](https://docs.medusajs.com/api/admin/customers/delete-a-customer).\n *\n * You can use this workflow within your customizations or your own custom workflows, allowing you to\n * delete customer accounts within your custom flows.\n *\n * :::note","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/core/core-flows/src/customer/workflows/remove-customer-account.ts#L25-L61","documentation":"getCustomerAuthIdentityStep throws NOT_FOUND when the first entry of the authIdentities array is empty — the customer has no linked auth identity to operate on.","triggerScenarios":"Running removeCustomerAccountWorkflow (or any workflow embedding getCustomerAuthIdentityStep) for a customer whose auth identity list is empty (guest customer, deleted/unlinked auth identity).","commonSituations":"Deleting a guest customer that never had an auth identity; auth identity already removed by a prior delete or unlink; customer created by admin/seeder without an auth link.","solutions":["Verify the customer has a linked auth identity before invoking the workflow (query auth identity via the auth module or customer with auth identities)","If the identity is already gone, remove the customer directly with deleteCustomerWorkflow","Guard against empty authIdentities in your caller and choose the customer-only deletion path"],"exampleFix":"// before\nawait removeCustomerAccountWorkflow(container).run({ input: { id, authIdentities: [] } })\n\n// after\nif (!authIdentities.length) {\n  await deleteCustomerWorkflow(container).run({ input: { ids: [id] } })\n} else {\n  await removeCustomerAccountWorkflow(container).run({ input: { id, authIdentities } })\n}","handlingStrategy":"type-guard","validationCode":"const authIdentity = input.authIdentities?.[0]\nif (!authIdentity) { /* skip auth deletion, only delete customer */ }","typeGuard":"const hasAuthIdentity = (i: { authIdentities?: unknown[] }) => !!i?.authIdentities?.[0]","tryCatchPattern":"try { await removeCustomerAccountWorkflow(scope).run({ input }) } catch (e) { if (e.type === MedusaError.Types.NOT_FOUND && /Auth identity/.test(e.message)) { await deleteCustomerWorkflow(scope).run({ input: { ids: [id] } }) } throw e }","preventionTips":["Check authIdentities.length before calling account removal","Fall back to plain customer deletion when no auth identity exists"],"tags":["customer","auth-identity","account-deletion"],"backgroundTag":"auth-identity-not-found","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}