Skip to content

Commit 6459b74

Browse files
authored
Merge branch 'main' into feat/automate_re_onboarding_for_stuck_repos
2 parents 179c84d + 6745534 commit 6459b74

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

  • services/libs/data-access-layer/src/organizations

services/libs/data-access-layer/src/organizations/base.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,8 @@ export async function findOrCreateOrganization(
450450
integrationId?: string,
451451
throttleUpdatedAt = false,
452452
): Promise<string | undefined> {
453-
const verifiedIdentities = data.identities ? data.identities.filter((i) => i.verified) : []
453+
data.identities = data.identities ?? []
454+
let verifiedIdentities = data.identities.filter((i) => i.verified)
454455

455456
if (verifiedIdentities.length === 0 && !data.displayName) {
456457
const message = `Missing organization identity or displayName while creating/updating organization!`
@@ -471,6 +472,16 @@ export async function findOrCreateOrganization(
471472

472473
data.identities = data.identities.filter((i) => i.value !== undefined)
473474

475+
// Re-derive after normalization may have set domain identity values to undefined
476+
verifiedIdentities = data.identities.filter((i) => i.verified)
477+
478+
if (verifiedIdentities.length === 0 && !data.displayName) {
479+
log.debug(
480+
'Organization has no valid verified identities after domain normalization and no displayName, skipping.',
481+
)
482+
return undefined
483+
}
484+
474485
let existing
475486
// find existing org by sent verified identities
476487
for (const identity of verifiedIdentities) {

0 commit comments

Comments
 (0)