fix(store): return transaction errors from rql search repositories#1768
fix(store): return transaction errors from rql search repositories#1768AmanGIT07 wants to merge 5 commits into
Conversation
WithTxn's return value was discarded in the org billing, org projects, org users, and project users search methods. A failed transaction begin or commit returned empty results with no error. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (5)
📝 WalkthroughSummary by CodeRabbit
WalkthroughFour PostgreSQL repository ChangesTransaction error propagation
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 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 29895848635Warning 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.3%) to 46.4%Details
Uncovered ChangesNo uncovered changes found. Coverage Regressions315 previously-covered lines in 8 files lost coverage.
Coverage Stats
💛 - Coveralls |
A canceled context makes the transaction begin fail. Each Search method must return that error instead of an empty result. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… files Each repository test file gets a Search case using a client whose connections always fail, so no database container is needed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: a7770ac2-b393-4c89-855f-cfae34c0a1b0
📒 Files selected for processing (5)
internal/store/postgres/fakes_test.gointernal/store/postgres/org_billing_repository_test.gointernal/store/postgres/org_projects_repository_test.gointernal/store/postgres/org_users_repository_test.gointernal/store/postgres/project_users_repository_test.go
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Summary
Search methods in four rql repositories discarded the error returned by
WithTxn. A failed transaction begin or commit produced an empty result with no error.Changes
WithTxnerror inOrgBillingRepository.Search,OrgProjectsRepository.Search,OrgUsersRepository.Search, andProjectUsersRepository.SearchTechnical Details
WithTxnreturns errors from transaction begin, commit, and the callback. Only callback errors reached the caller, through a captured outer variable. InOrgBillingRepository.Searchthe group-by branch shadowed that variable, so its failures were dropped as well.Test Plan
go test ./internal/store/postgres/passes (covers the four Search methods)SQL Safety (if your PR touches
*_repository.goorgoqu.*)?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(usemake_interval(hours => ?)-style functions instead).//nolint:forbidigoor// #nosec G20xannotation has a one-line justification on the same line that a reviewer can verify.