Skip to content

fix: recalculate affiliations on update member orgs (IN-1083)#4039

Closed
ulemons wants to merge 9 commits intomainfrom
fix/update-member-organizations
Closed

fix: recalculate affiliations on update member orgs (IN-1083)#4039
ulemons wants to merge 9 commits intomainfrom
fix/update-member-organizations

Conversation

@ulemons
Copy link
Copy Markdown
Contributor

@ulemons ulemons commented Apr 21, 2026

Note

Medium Risk
Changes workflow triggering and the set of organization IDs used for affiliation recomputation, which can affect correctness/performance of affiliation data if mis-scoped or called too often.

Overview
Ensures member affiliation data is recalculated whenever a member’s organizations are added/updated.

On backend member upsert/update, the code now fetches existing organization IDs and triggers CommonMemberService.startAffiliationRecalculation with the union of old + new org IDs so removals and additions are both covered. The data sink worker also triggers the recalculation workflow after it adds organizations to a member, and updateMemberOrganizations now normalizes org inputs consistently; startAffiliationRecalculation adds structured logging before starting the Temporal workflow.

Reviewed by Cursor Bugbot for commit b65c266. Bugbot is set up for automated code reviews on this repo. Configure here.

@ulemons ulemons self-assigned this Apr 21, 2026
Copilot AI review requested due to automatic review settings April 21, 2026 12:44
@ulemons ulemons added the Bug Created by Linear-GitHub Sync label Apr 21, 2026
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@ulemons ulemons marked this pull request as ready for review April 21, 2026 12:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR ensures member affiliation data is recalculated after a member’s work experiences (member organizations) are updated, by tracking which organizations were affected and triggering the existing Temporal memberUpdate workflow.

Changes:

  • Track organization IDs affected by member-organization deletes/creates/updates during updateMemberOrganizations.
  • Trigger startAffiliationRecalculation after the update to recompute affiliations (and currently force OpenSearch sync).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread services/libs/common_services/src/services/common.member.service.ts
Comment thread services/libs/common_services/src/services/common.member.service.ts Outdated
@ulemons ulemons requested a review from skwowet April 21, 2026 12:57
Comment thread services/libs/common_services/src/services/common.member.service.ts Outdated
Copilot AI review requested due to automatic review settings April 21, 2026 15:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread services/libs/common_services/src/services/common.member.service.ts
Comment thread services/libs/common_services/src/services/common.member.service.ts Outdated
Comment thread backend/src/database/repositories/memberRepository.ts Outdated
Comment thread backend/src/database/repositories/memberRepository.ts Outdated
Comment thread backend/src/database/repositories/memberRepository.ts Outdated
Comment thread services/libs/common_services/src/services/common.member.service.ts Outdated
Copilot AI review requested due to automatic review settings April 22, 2026 09:01
ulemons added 6 commits April 22, 2026 11:01
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread services/libs/common_services/src/services/common.member.service.ts
Comment thread backend/src/services/memberService.ts
Comment thread backend/src/services/memberService.ts Outdated
Comment thread backend/src/services/memberService.ts
Comment thread services/libs/common_services/src/services/common.member.service.ts
Comment thread backend/src/services/memberService.ts Outdated
Comment thread backend/src/services/memberService.ts Outdated
Comment thread backend/src/services/memberService.ts Outdated
ulemons added 2 commits April 22, 2026 13:43
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Copilot AI review requested due to automatic review settings April 22, 2026 11:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread services/libs/common_services/src/services/common.member.service.ts
Comment thread backend/src/services/memberService.ts
Comment thread backend/src/services/memberService.ts
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b65c266. Configure here.

await commonMemberService.startAffiliationRecalculation(
id,
(data.organizations || []).map((o) => o.id),
allAffectedOrgIds,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary Temporal workflow on every member update

Medium Severity

In the update method, startAffiliationRecalculation is called unconditionally — even when data.organizations is falsy and no org changes occurred. When there are no orgs, both existingOrgIds and newOrgIds are empty, yet a Temporal memberUpdate workflow is still started (calling refreshMemberOrganizationAffiliations). The upsert method correctly guards this with if (data.organizations), but the update method lacks this guard. Every member field update (e.g. displayName) unnecessarily triggers an affiliation recalculation workflow.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b65c266. Configure here.

@ulemons ulemons closed this Apr 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Created by Linear-GitHub Sync

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants