File tree Expand file tree Collapse file tree
services/libs/data-access-layer/src/organizations Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ) {
You can’t perform that action at this time.
0 commit comments