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,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 ) {
You can’t perform that action at this time.
0 commit comments