refactor(deleter): move custom-resource policy cleanup to resource service#1800
refactor(deleter): move custom-resource policy cleanup to resource service#1800whoAbhishekSah wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
Next review available in: 49 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthroughResource services now remove principal policies scoped to organization projects. Organization member removal delegates this cleanup before membership removal, with updated constructor wiring, mocks, and tests. ChangesPrincipal access cleanup
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
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. Comment |
3789133 to
fbfd35d
Compare
Coverage Report for CI Build 30066468066Coverage increased (+0.02%) to 46.759%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
fbfd35d to
f1ab523
Compare
…rvice When a user is deleted, the deleter walked the user's policies itself and deleted the ones on custom resources. That was the last place it removed access without going through a domain service. Move that cleanup into the resource service as RemovePrincipalAccess. The deleter now calls it once per user and no longer touches policies directly for this path. Behavior is unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
f1ab523 to
e9f9e55
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (2)
core/resource/service_test.go (1)
561-582: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a multi-project case to
TestRemovePrincipalAccess.Current tests only pass a single project ID. A case with two+
projectIDs(each contributing distinct resources toprojectResourceIDs) would directly cover the map-merging logic across projects.core/resource/service.go (1)
473-484: 🚀 Performance & Scalability | 🔵 Trivial | ⚖️ Poor tradeoffConsider batching resource lookups for the delete path.
RemovePrincipalAccesscurrently callsrepository.Listonce per project, andresource.Filter.ProjectIDonly supports a single project at a time. If this path can be extended to list resources for many projects in one query, it would avoid N sequential DB calls before deleting related policies.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: df8088e1-0ade-4bb4-89bb-719866b4d7a6
📒 Files selected for processing (7)
cmd/serve.gocore/deleter/mocks/resource_service.gocore/deleter/service.gocore/deleter/service_test.gocore/resource/mocks/policy_service.gocore/resource/service.gocore/resource/service_test.go
|
Tested the Setup
Results
Note on the gap: |
What
When a user is deleted, the deleter walked the user's policies itself and deleted the ones on custom resources. That was the last spot where it removed access without going through a domain service.
This moves that cleanup into the resource service, as a new method
RemovePrincipalAccess. The deleter now calls it once per user and no longer touches policies directly for this path.Behavior
Unchanged. Deleting a user still removes their access to resources in the org's projects. Org, project, and group membership is still handled by the membership cascade.
🤖 Generated with Claude Code