Join identities in MembershipProfiles.LoadExistingByIDs
SCIM event CSV exports failed with "cannot parse address : mail: no address" because this query selected a placeholder empty string for email_address instead of the real address, and scanning it into mail.Addr tried to parse it as one. Join identities the same way every other MembershipProfile query already does, and drop the redundant identity lookup in the SCIM export path now that profiles carry their real email address. Signed-off-by: Bryan Frimin <bryan@probo.com>
This commit is contained in:
@@ -506,7 +506,7 @@ SELECT
|
||||
p.id,
|
||||
p.identity_id,
|
||||
p.organization_id,
|
||||
''::citext AS email_address,
|
||||
i.email_address,
|
||||
p.source,
|
||||
p.state,
|
||||
p.full_name,
|
||||
@@ -541,6 +541,8 @@ SELECT
|
||||
p.updated_at
|
||||
FROM
|
||||
iam_membership_profiles p
|
||||
INNER JOIN identities i
|
||||
ON i.id = p.identity_id
|
||||
WHERE
|
||||
p.%s
|
||||
AND p.id = ANY(@profile_ids)
|
||||
|
||||
@@ -307,28 +307,13 @@ func loadSCIMProfileExportInfo(
|
||||
return scimProfileExportLookup{}, fmt.Errorf("cannot load SCIM export profiles: %w", err)
|
||||
}
|
||||
|
||||
identityIDs := make([]gid.GID, 0, len(profiles))
|
||||
for _, profile := range profiles {
|
||||
identityIDs = append(identityIDs, profile.IdentityID)
|
||||
}
|
||||
|
||||
var identities coredata.Identities
|
||||
if err := identities.LoadByIDs(ctx, conn, identityIDs); err != nil {
|
||||
return scimProfileExportLookup{}, fmt.Errorf("cannot load SCIM profile identity emails: %w", err)
|
||||
}
|
||||
|
||||
emailByIdentityID := make(map[gid.GID]string, len(identities))
|
||||
for _, identity := range identities {
|
||||
emailByIdentityID[identity.ID] = identity.EmailAddress.String()
|
||||
}
|
||||
|
||||
lookup := scimProfileExportLookup{
|
||||
byProfileID: make(map[gid.GID]scimProfileExportInfo, len(profiles)),
|
||||
byUserName: make(map[string]scimProfileExportInfo, len(profiles)),
|
||||
}
|
||||
for _, profile := range profiles {
|
||||
info := scimProfileExportInfo{
|
||||
email: emailByIdentityID[profile.IdentityID],
|
||||
email: profile.EmailAddress.String(),
|
||||
fullName: profileFullName(profile),
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user