Skip to content

fix: return 404 when merging a member that no longer exists - #4531

Merged
skwowet merged 1 commit into
mainfrom
fix/member-merge-404-missing-members
Aug 28, 2026
Merged

fix: return 404 when merging a member that no longer exists#4531
skwowet merged 1 commit into
mainfrom
fix/member-merge-404-missing-members

Conversation

@skwowet

@skwowet skwowet commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

Merge suggestions can still send a merge against a profile that was just merged away. After a successful merge we hard-delete the extra member. If the UI still has that id (next suggestion already on screen, or a retry), we try to move identities onto a member that no longer exists.

Postgres then fails with memberIdentities_memberId_fkey (insert or update on table "memberIdentities" violates foreign key constraint). The API returns 500 and Slack reports API Error 500: PUT /member/:id/merge / SequelizeForeignKeyConstraintError.

That is a stale request, not bad identity data. The leftover profile should stay put; a new suggestion can pair it with whoever is still alive.

Changes

  • Return 404 if either member is gone, before any identity updates. The suggestions UI already treats 404 as “already merged or deleted” and loads the next pair.
  • Treat that 404 as a skip in merge workers so Temporal does not retry the deleted id.

Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings August 28, 2026 15:28
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Prevents stale member merges from returning 500 errors and repeatedly retrying in Temporal workers.

Changes:

  • Return 404 when either member no longer exists.
  • Treat that 404 as a successful no-op in three merge activities.
  • Avoid marking missing-member merges as failed.

Review note: The PR title is missing the required (CM-XXX) JIRA key.

Reviewed changes

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

File Description
services/libs/common_services/src/services/common.member.service.ts Adds member existence validation and 404 propagation.
services/apps/script_executor_worker/src/activities/common.ts Stops retries for missing members.
services/apps/merge_suggestions_worker/src/activities/common.ts Stops retries for missing members.
services/apps/members_enrichment_worker/src/activities/member.ts Stops retries for missing members.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@skwowet
skwowet merged commit cde5fa1 into main Aug 28, 2026
18 checks passed
@skwowet
skwowet deleted the fix/member-merge-404-missing-members branch August 28, 2026 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants