fix: keep LFX organizations as primary in merge suggestions#4106
Conversation
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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 64da245. Configure here.
There was a problem hiding this comment.
Pull request overview
This PR adjusts organization merge suggestion generation so that organizations with an LFX membership are placed in the primary position, preventing downstream merge failures where the merge API rejects LFX organizations as the secondary.
Changes:
- Convert the OpenSearch candidate org once (
secondaryOrg) and reuse it for similarity + ordering. - Add LFX-aware ordering logic that swaps primary/secondary when the candidate (secondary) has LFX membership and the current org (primary) does not.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ggestions Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>

What changed
In
getOrganizationMergeSuggestions, when generating organization merge suggestions, if the secondary candidate has an LFX membership and the primary does not, the two are now swapped so the LFX org becomes primary.Why
LFX membership organizations cannot be merged as secondary, and the merge API hard-rejects these cases at runtime. By ensuring they’re always set as primary during suggestion creation, we prevent invalid ordering from entering the pipeline and avoid silently failed merges caused by this constraint.
Note
Medium Risk
Changes merge-suggestion ordering logic, which can affect which organization is treated as the merge primary/secondary and therefore downstream merge behavior. Risk is limited to suggestion generation but could alter merge outcomes for LFX-related candidates.
Overview
Updates
getOrganizationMergeSuggestionsto force LFX-member organizations to be the primary when building merge suggestions: if only one side has LFX membership, the pair is ordered so the LFX org comes first; otherwise it falls back to the existing identities/activity-based sort. Also avoids repeatedopensearchToFullOrgconversions by materializing the secondary org once before scoring and ordering.Reviewed by Cursor Bugbot for commit 359a056. Bugbot is set up for automated code reviews on this repo. Configure here.