feat(store): org tokens search skips soft-deleted rows - #1950
rohilsurana wants to merge 2 commits into
Conversation
|
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 organization token query now excludes soft-deleted billing transactions, customers, organizations, and users. Updated SQL expectations and PostgreSQL integration tests cover the filtering behavior. ChangesOrganization token filtering
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to No actionable merge-blocking risk is identified for the token-search change after normal checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change narrows token visibility for deleted organizations and related records while preserving tokens whose user has been deleted. No newly exposed data path was identified. The remaining uncertainty is about surrounding access controls and future deletion behavior, not an observed flaw in this change. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
🚥 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 36121381379Coverage increased (+0.1%) to 52.211%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
b8a258c to
e692021
Compare
e692021 to
e97dd66
Compare
e97dd66 to
127134a
Compare
127134a to
7bd0f5d
Compare
Last of the org view repositories. Same shape as #1939, #1943, #1945, #1946, #1947.
Summary
The org tokens search now skips soft-deleted transactions, billing accounts and organizations. A soft-deleted user no longer lends their name to a token.
Changes
fromLive(billing_transactions), addlive(billing_customers).organizationsand addlive(organizations), like feat(store): project users search skips soft-deleted rows #1946 and feat(store): org service user credentials search skips soft-deleted rows #1949. The search is scoped bybilling_customers.org_id, and a billing account is not soft-deleted when its org goes, so without this a soft-deleted org still listed its tokens.live(users)goes in the left join, not the where clause. The token stays, the deleted user's name and avatar come back empty. Dropping the row would change the totals an org sees.org_tokens_repository_pg_test.go. Updated expected SQL inorg_tokens_repository_test.go.Notes for review
billing_transactions.deleted_atyet. The filter is here for when deleting an org becomes a soft delete and takes its transactions with it.user_idstill comes back for a deleted user, only the name is gone.billing_transactions_repository.goreads the same table for the balance and the org's own list, with no filter. Once orgs are soft-deleted the two views will disagree. Tracked in CLD-3632.Test Plan
go test -run 'TestOrgTokensRepository' ./internal/store/postgres/passesmain, naming the soft-deleted transaction, account, org and usergolangci-lint run ./internal/store/postgres/...is cleanSQL 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.