Skip to content

fix(membership): member removal covers disabled projects and groups - #2049

Merged
AmanGIT07 merged 1 commit into
mainfrom
fix/member-removal-disabled-projects-groups
Nov 17, 2026
Merged

AmanGIT07 merged 1 commit into
mainfrom
fix/member-removal-disabled-projects-groups

Conversation

@AmanGIT07

@AmanGIT07 AmanGIT07 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Removing a member from an organization now also removes their access on disabled projects and groups. Stacked on #2048.

Changes

  • cascadeRemovePrincipal lists the organization's projects and groups with IncludeDisabled: true. The member's policies on disabled projects and groups, their policies on custom resources in disabled projects, and their member relation on disabled groups are removed with the rest.
  • The membership tests expect the new list filters.

Technical Details

  • Enabling a project or group again does not give a removed member their access back.
  • The deleter already lists projects and groups with IncludeDisabled: true.
  • User delete does not change. It already ends by removing all of the user's policies and every relation they are in, and TestUserDeleteLeavesNoAccessAndNoLivePolicy already covers a disabled project and group.
  • Service users do not reach this removal. The endpoint refuses them, and service user delete removes their policies and relations itself.

Test Plan

  • go test ./core/membership/ passes. The removal and user delete tests expect IncludeDisabled: true on both lists. Without the flag, 18 cases fail.
  • e2e TestOrgMemberRemovalLeavesNoAccessOnDisabledProjectsAndGroups: a member holds a role on a project, a group, and an order in that project, and the group holds viewer on a second project. The project and group are disabled, the member is removed, and both are enabled again. No live policy is left, the member has no get on any of them, and the group no longer gives access to the second project. Without the fix, all three checks fail.
  • go test ./test/e2e/... passes.
  • make test passes.
  • golangci-lint run reports no issues.

@vercel

vercel Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
frontier Ready Ready Preview Nov 16, 2026 10:17am UTC

@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Removing an organization member now also removes their access to projects and groups that were disabled at the time of removal. This prevents access from reappearing if those resources are later enabled.
    • Access granted through a group is also cleaned up when the member is removed, including access to disabled projects.

Organization member removal now includes disabled projects and groups when it identifies policies and relations for cleanup. Unit tests cover the updated query filters, and an end-to-end regression test checks access after disabled resources are re-enabled.

Changes: Member removal cleanup

Layer / File(s) Summary
Removal cascade and unit coverage
core/membership/org.go, core/membership/org_test.go
cascadeRemovePrincipal now includes disabled projects and groups in its listings. Unit tests expect these filters across removal and cleanup cases.
End-to-end regression coverage
test/e2e/regression/api_test.go
The test removes a member while a project and group are disabled, then checks that user and group policies do not grant access after re-enabling them.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Suggested reviewers: whoabhisheksah

Merge Risk: Moderate · up to fe9df

This PR makes organization member removal also clean up access on disabled projects and groups, so re-enabling them no longer restores a removed member's access. The change is small and well covered by tests. One earlier open concern remains: if cleanup fails partway during removal, the member's personal access tokens may not be revoked. Resolve or explicitly accept that before merging.

Pre-merge checks: Passed 2

Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between cad5c3c and fe9dfac.

Files selected for processing: 2

  • core/membership/org.go
  • core/membership/org_test.go

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

@coveralls

coveralls commented Nov 11, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 43847390748

Coverage remained the same at 56.097%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: 2 of 2 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 42232
Covered Lines: 23691
Line Coverage: 56.1%
Coverage Strength: 21.71 hits per line

💛 - Coveralls

@rohilsurana rohilsurana left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The fix looks right. Both list calls now include disabled projects and groups, and the postgres repos honor the flag. The project list also feeds the custom resource cleanup, so orders in a disabled project get cleaned up too.

I ran the new e2e test locally. It passes with the fix. With the old org.go all three sub tests fail. Unit tests and lint pass.

Two things for later, not for this PR:

  • Removing someone straight from a disabled project or group still fails with "not found". RemoveProjectMember, SetGroupMemberRole and RemoveGroupMember call Get, and GetByID skips disabled rows. Worth a follow up issue.
  • Members removed before this fix may still have live policies and group relations on disabled projects and groups. Do we want a one time cleanup, or is it fine to leave them?

Comment thread test/e2e/regression/api_test.go Resolved
@AmanGIT07

AmanGIT07 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor Author

On the two things for later:

  1. Removing someone straight from a disabled project or group: agreed. SetProjectMemberRole, RemoveProjectMember, SetGroupMemberRole and RemoveGroupMember all load the project or group first, and GetByID skips disabled rows. Follow-up issue: Removing a member from a disabled project or group fails with not found #2051.
  2. Members removed before this fix: removing them again won't clean these up, because the member check stops before the cleanup runs. Whether a one-time cleanup is needed depends on live data, which has to be checked first. We will decide after that, not now.

Base automatically changed from fix/revoke-pats-on-member-removal to main November 16, 2026 09:21

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 2d93a34 and cad5c3c.

Files selected for processing: 8

  • core/membership/mocks/user_pat_service.go
  • core/membership/org.go
  • core/membership/org_test.go
  • core/membership/service.go
  • core/userpat/service.go
  • core/userpat/service_test.go
  • test/e2e/regression/api_test.go
  • test/e2e/regression/pat_test.go

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

Comment thread core/membership/org.go Resolved
cascadeRemovePrincipal now lists the org's projects and groups with IncludeDisabled, so a removed member's policies there, their custom-resource policies in disabled projects, and their group member relations are removed too.
@AmanGIT07
AmanGIT07 force-pushed the fix/member-removal-disabled-projects-groups branch from cad5c3c to fe9dfac Compare November 16, 2026 10:16
@AmanGIT07
AmanGIT07 merged commit d34a173 into main Nov 17, 2026
8 checks passed
@AmanGIT07
AmanGIT07 deleted the fix/member-removal-disabled-projects-groups branch November 17, 2026 06:38

This branch was successfully deployed

1 active deployment
Preview — fe9dfaca Deployed Nov 16, 2026 by vercel[bot]
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.

3 participants