Conversation
Both the listing and the group-by count read invoices and billing customers through the live-row helpers, and join organizations so a soft-deleted org reports nothing.
…-deleted rows Seeds a soft-deleted invoice, one under a soft-deleted billing customer, and one under a soft-deleted organization, then checks the listing and the group counts.
|
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; 0 remain after this review. 📝 SummarySummary by CodeRabbit
WalkthroughThe organization invoice queries now exclude soft-deleted invoices, customers, and organizations. Updated query expectations and PostgreSQL integration tests cover invoice search and grouped counts. ChangesOrganization invoice queries
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to The invoice listing and grouped counts are intended to exclude soft-deleted records. No actionable issue is established; the PR is mergeable after normal checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change narrows invoice search results to live invoices belonging to live customers and organizations. The existing organization access check and organization filter remain in place. No new exposure was identified, although security coverage is incomplete. 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 36114276913Coverage increased (+0.2%) to 52.281%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
Seventh of the org view repositories. Follows #1947 and #1949.
Summary
The organization invoices search leaves out soft-deleted invoices, billing customers, and organizations. The change covers both of the repository's query paths, the listing and the group-by count.
Changes
fromLive(billing_invoices)and addliveon the joined billing customers.liveon it, so a soft-deleted organization reports nothing.org_invoices_repository_pg_test.go: seeds a soft-deleted invoice, one under a soft-deleted billing customer, and one under a soft-deleted organization, then checks the listing and the group counts.Technical Details
This repository builds two queries.
buildBaseQueryreturns the rows andprepareGroupByQueryreturns the per-state counts shown above them. Filtering only the first would have left the summary counting rows the list no longer shows.All three tables have carried
deleted_atsince they were created.The join is on the organizations primary key, so it matches at most one row and cannot duplicate invoices.
Frontier does not set
deleted_aton these tables yet, so the search returns the same rows as before.Test Plan
go test -run 'TestOrgInvoices' ./internal/store/postgres/passes (unit tests and the new suite)main, including the group countsgolangci-lint run ./internal/store/postgres/...reports no issuesFrontierService/SearchOrganizationInvoices. Two orgs were created through the public RPCs; billing customers and invoices were inserted by SQL because the sandbox has no billing provider configured.deleted_atwas then set by SQL. The same scenarios ran againstmainon the same database, with only the binary swapped.On
mainthe counts came back as two paid and one open while the list showed three rows, two of which should have been hidden.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.