Skip to content

Commit 7ca2302

Browse files
committed
fix: issue with org data preparation
Signed-off-by: Uroš Marolt <uros@marolt.me>
1 parent bff105f commit 7ca2302

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

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

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ 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+
let verifiedIdentities = data.identities ? data.identities.filter((i) => i.verified) : []
454454

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

472472
data.identities = data.identities.filter((i) => i.value !== undefined)
473473

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

0 commit comments

Comments
 (0)