fix(deleter): cascade PAT cleanup on user delete#1672
Conversation
User delete dropped user_pats rows via ON DELETE CASCADE but left their policies entries and SpiceDB rolebinding tuples orphaned. DeleteUser now invokes userpat.Service.DeleteAllByUser before the user row is removed so each PAT's authorization data is cleaned via the existing per-PAT delete cascade. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThis PR adds Repository.ListByUser and UserPATService.DeleteAllByUser, implements Postgres ListByUser, implements DeleteAllByUser in the PAT service (and adjusts Delete), wires UserPATService into the cascade deleter (calling PAT cleanup before user deletion), updates mocks and tests, and threads the dependency through bootstrap wiring. ChangesUser PAT Cascade Deletion on Account Removal
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: aac181e7-782b-4d7c-a2f1-f0728e4d65c7
📒 Files selected for processing (10)
cmd/serve.gocore/deleter/mocks/user_pat_service.gocore/deleter/service.gocore/deleter/service_test.gocore/userpat/mocks/repository.gocore/userpat/service.gocore/userpat/service_test.gocore/userpat/userpat.gointernal/store/postgres/userpat_repository.gointernal/store/postgres/userpat_repository_test.go
Coverage Report for CI Build 26893496588Coverage increased (+0.08%) to 43.236%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
Both gates short-circuited the cascade user-delete path: with PATs created while enabled and later disabled, DeleteAllByUser bailed and user_pats rows were cascade-removed without their policies or SpiceDB tuples. Revocation should always work regardless of feature exposure. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Test results
|
Summary
DeleteUsercascades to the user's PATs before removing the user row, cleaningpoliciesrows and SpiceDB rolebinding tuples that were previously orphaned.userpat.Service.DeleteAllByUserreuses the existing per-PAT delete cascade.ListByUserreturns active PATs for a user across all orgs.Test plan
go test ./core/userpat/... ./core/deleter/...go test ./internal/store/postgres/...make lintpoliciesrows for those PATs are gone and no rolebinding tuples for the PATs remain in SpiceDB.Addresses (#1660)