Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions services/apps/data_sink_worker/src/service/member.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
IMemberData,
IMemberIdentity,
IOrganizationIdSource,
MemberAttributeName,
MemberBotDetection,
MemberIdentityType,
OrganizationAttributeSource,
Expand Down Expand Up @@ -301,7 +302,7 @@ export default class MemberService extends LoggerBase {
data.displayName = getProperDisplayName(data.displayName)
}

const toUpdate = MemberService.mergeData(original, originalIdentities, data)
const toUpdate = this.mergeData(original, originalIdentities, data)

if (toUpdate.attributes) {
this.log.trace({ memberId: id }, 'Setting attribute default values!')
Expand Down Expand Up @@ -627,7 +628,7 @@ export default class MemberService extends LoggerBase {
return toReturn
}

private static mergeData(
private mergeData(
dbMember: IDbMember,
dbIdentities: IMemberIdentity[],
member: IMemberUpdateData,
Expand Down Expand Up @@ -674,6 +675,21 @@ export default class MemberService extends LoggerBase {

let attributes: Record<string, unknown> | undefined
if (member.attributes) {
const incomingIsBot = member.attributes?.[MemberAttributeName.IS_BOT]?.[PlatformType.GITHUB]
const existingIsBot = dbMember.attributes?.[MemberAttributeName.IS_BOT]?.[PlatformType.GITHUB]

// Incoming data flags the member as a bot, but the existing record does not
// This is likely corrupted; discard the incoming attributes
// If the member were actually a bot, the flag would have been set at creation.
if (incomingIsBot && !existingIsBot) {
this.log.warn(
{ memberId: dbMember.id },
'Member attributes appear corrupted due to bot attributes',
)

member.attributes = {} // Preserve existing member attributes
}

const temp = mergeWith({}, dbMember.attributes, member.attributes)
const manuallyChangedFields: string[] = dbMember.manuallyChangedFields || []

Expand Down
Loading