Repository navigation
feat(store): user organizations search skips soft-deleted rows - #1947
Conversation
The search reads policies, roles, organizations, and users through the live-row helpers. The project count already skipped deleted projects and now uses the helper too.
Its last two uses move to the live helper, which builds the same SQL.
…h soft-deleted rows Seeds a soft-deleted organization, grant, role, user, and project, then checks the listing, the reported roles, and the project count.
|
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 (5)
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review. 📝 SummarySummary by CodeRabbit
WalkthroughPostgreSQL user organization and project queries now use live-row helpers to filter soft-deleted records. The changes also remove an exported constant and add SQL expectation updates and Docker-backed integration tests for search results. ChangesPostgreSQL repository filtering
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to The search changes and their PostgreSQL tests present no identified issue requiring resolution before merge. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The search now hides soft-deleted records without adding an entrypoint or widening access. An empty organization listing should not, however, be treated as proof that every other user-scoped read has been revoked. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Hardening Proposals
🚥 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 36101719227Coverage increased (+0.1%) to 51.89%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
Fifth of the org view repositories. Follows #1945 and #1946.
Summary
The user organizations search leaves out soft-deleted organizations, policies, roles, and users. It also drops the last copy of the
deleted_atcolumn constant.Changes
fromLive(policies)and addsliveon the joined roles, organizations, and users.fromLive(projects)in place of its hand-written null check. It already skipped soft-deleted projects.COLUMN_DELETED_ATis removed. Its last two uses, in the user projects query, move to thelivehelper and build byte-identical SQL, so no pinned test changed. feat(store): user projects search skips soft-deleted rows #1945 makes the same two-line change, so the branches merge cleanly in either order.user_orgs_repository_pg_test.go: seeds a soft-deleted organization, grant, role, user, and project, then checks the listing, the reported roles, and the project count.Technical Details
This query already joined users, so filtering there means a soft-deleted user gets an empty list, the same answer as a user id nobody owns. The user projects search has no such join and is unaffected.
Frontier does not set
deleted_aton these tables yet, so the search returns the same rows as before.Test Plan
go test -run 'TestUserOrgsRepository' ./internal/store/postgres/passes (unit tests and the new suite)maingolangci-lint run ./internal/store/postgres/...reports no issuesAdminService/SearchUserOrganizations. Three orgs, two members, a custom role and three projects were created through the public RPCs, thendeleted_atwas set by SQL. The same scenarios ran againstmainon the same database, with only the binary swapped.role_namesproject_countskips the soft-deleted projectSQL Safety
?placeholders,goqu.Ex{}, orgoqu.Record{}— neverfmt.Sprintfor+building a query that gets executed.ToSQL()callers capture and forward params (query, params, err := stmt.ToSQL(); db.…Context(ctx, …, query, params...)). Neverquery, _, err := ….?placeholders inside single-quoted SQL literals ingoqu.L.//nolint:forbidigoor// #nosec G20xannotations.