Repository navigation
feat(store): project users search skips soft-deleted rows - #1946
Conversation
The search reads policies, users, and roles through the live-row helpers, and joins projects so a soft-deleted project reports no members, the same as a project id nobody owns.
…t-deleted rows Seeds a soft-deleted user, grant, role, and project, then checks the member list, the reported roles, and the text search.
|
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 (3)
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review. 📝 SummarySummary by CodeRabbit
WalkthroughThe project users query now filters soft-deleted policies, projects, users, and roles. SQL expectations and PostgreSQL integration tests cover the query and search results. ChangesProject user search
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to No actionable issue is established in the project-user search change; it is mergeable after normal checks. 🚥 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 35991795059Coverage increased (+0.08%) to 51.838%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
Fourth of the org view repositories. Follows #1943 and #1945.
Summary
The project users search leaves out soft-deleted policies, users, and roles. It also joins projects, so a soft-deleted project reports no members.
Changes
fromLive(policies)and addsliveon the joined users and roles.liveon it. Without this, a soft-deleted project still returns its members whenever their grants are untouched.project_users_repository_pg_test.go: seeds a soft-deleted user, a soft-deleted grant, a member whose role is soft-deleted, and a soft-deleted project, then checks the member list, the reported roles, and the text search.Technical Details
The project id arrives as a request parameter and the handler passes it straight through. Before this change the three possible ids answered three different ways: an unknown id returned an empty list, a soft-deleted project returned its members, and a malformed id returned an internal error. The new join makes the first two agree. The malformed id is unchanged here and is tracked separately, since ten aggregate searches share that gap.
The join is on the projects primary key, so it matches at most one row and cannot duplicate members or change the grouping.
Frontier does not set
deleted_aton these tables yet, so the search returns the same rows as before.Test Plan
go test -run 'TestProjectUsersRepository' ./internal/store/postgres/passes (unit tests and the new suite)maingolangci-lint run ./internal/store/postgres/...reports no issuesAdminService/SearchProjectUsers. An org, two projects and four members were created through the public RPCs, thendeleted_atwas set by SQL. The same scenarios ran againstmainon the same database, with only the binary swapped.SQL 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.