Repository navigation
feat(store): policy, relation, and resource reads skip soft-deleted rows - #1936
Conversation
Every read in the three repositories goes through fromLive, or adds the live filter directly where the query aliases the table. The policy repository's small lookups of organization, project, and group titles for audit records use fromLive too. The two updates keyed by id add the filter as well. The ON CONFLICT upserts are unchanged. They move with the unique constraints in a later change.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: raystack/frontier/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (4)
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review. 📝 SummarySummary by CodeRabbit
WalkthroughPostgreSQL policy, relation, and resource repositories now use live-row filters for reads and applicable updates. Tests verify that soft-deleted records are excluded and return not-exist or conflict errors where applicable. ChangesRepository live-row filtering
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Feature Suggested reviewers: Merge Risk: ⚪ Minimal · up to Repository operations now hide soft-deleted records while preserving expected conflict and guarded-deletion behavior. The covered tests show no actionable merge-blocking risk remains. 🚥 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 |
Coverage Report for CI Build 35692027216Warning Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes. Coverage increased (+0.4%) to 50.738%Details
Uncovered Changes
Coverage Regressions5 previously-covered lines in 2 files lost coverage.
Coverage Stats
💛 - Coveralls |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID: afc335bf-b2e4-4815-9d2b-9a3083fff1eb
📒 Files selected for processing (6)
internal/store/postgres/policy_repository.gointernal/store/postgres/policy_repository_test.gointernal/store/postgres/relation_repository.gointernal/store/postgres/relation_repository_test.gointernal/store/postgres/resource_repository.gointernal/store/postgres/resource_repository_test.go
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.
|
Tested live on a local server built from this branch (main with #1931 merged). Fixtures: a user with an org viewer policy, a project viewer policy, and a platform admin relation, plus two custom resources under a live project. Ran every affected RPC before and after setting
Write paths against a hidden row, worth noting for the phased plan:
No behaviour change today since no row has |
The create upsert targets urn only. An insert that reuses an existing id with a different urn fails on the primary key and fell through to a raw duplicate key error. It now maps to resource.ErrConflict, which the handler already turns into a conflict response. With live-only reads the id of a soft-deleted row is invisible to the pre-check, so this path is easier to reach.
|
About RemovePlatformUser and DeleteRelation returning success but doing nothing on a hidden row, from your testing note: is that fix meant for this PR, or is it planned for later? If later, which change will pick it up? |
…eads The last-owner guard counted soft-deleted holders of the guarded role, so a deleted owner policy would have let the last live owner be removed. The locked CTE now counts live rows only, with a test that soft-deletes one of the holders. The lookups of organization, project, and group titles for the policy audit record go back to the plain From. They only attribute the audit record, and the trail must stay attributed after the parent is deleted. The roles join in the policy list query only matches live roles. The relation and resource tests list with no filter and compare counts, so the check runs on real rows instead of an empty result.
|
On RemovePlatformUser and DeleteRelation returning success on a hidden row: not this PR. The relation service already returned nil for a relation that was never there, so this is the existing behaviour showing up on hidden rows. Future work on relation writes will decide whether a miss should become not found. The org delete cascade removes memberships that may already be gone, so that decision needs to check it does not rely on the delete being repeatable. |
Second of three PRs that make the identity repositories skip soft-deleted rows. Follows #1931.
What
fromLive, or addslive("p")directly where the query aliases the table.fromLivetoo.livefilter.ON CONFLICTupserts are unchanged. They move together with the unique constraints in a later PR.Behaviour change
None today. No row has
deleted_atset yet.Tested
One new test per repository: soft-delete a seeded row, then check every get, list, count, and update skips it. Store package passes with
-race.