From 19dbde8a3cde0a2c7682a99d511b183cfa4d5b78 Mon Sep 17 00:00:00 2001 From: Hariom Balhara Date: Thu, 19 Jun 2025 11:25:42 +0530 Subject: [PATCH] Add comment (#21920) --- .../lib/server/createOrganizationFromOnboarding.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/features/ee/organizations/lib/server/createOrganizationFromOnboarding.ts b/packages/features/ee/organizations/lib/server/createOrganizationFromOnboarding.ts index 0c9b767ad8..6bb139e631 100644 --- a/packages/features/ee/organizations/lib/server/createOrganizationFromOnboarding.ts +++ b/packages/features/ee/organizations/lib/server/createOrganizationFromOnboarding.ts @@ -197,6 +197,9 @@ async function createOrganizationWithNonExistentUserAsOwner({ ); const owner = await findUserToBeOrgOwner(email); if (!owner) { + // Can happen when the organization was created earlier and the webhook had failed and when the webhook got fired again in next subscription update, then the email was deleted already + // The fix would be to change the email in Onboarding record to new owner of the organization + // TODO: Identify the owner of the organization from Membership table and use that email instead here. throw new Error(`Org exists but owner could not be found for email: ${email}`); } return { organization, owner };