Skip to content

fix(store): return transaction errors from rql search repositories#1768

Open
AmanGIT07 wants to merge 3 commits into
mainfrom
fix/search-txn-errors
Open

fix(store): return transaction errors from rql search repositories#1768
AmanGIT07 wants to merge 3 commits into
mainfrom
fix/search-txn-errors

Conversation

@AmanGIT07

Copy link
Copy Markdown
Contributor

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

  • Capture and return the WithTxn error in OrgBillingRepository.Search, OrgProjectsRepository.Search, OrgUsersRepository.Search, and ProjectUsersRepository.Search

Technical Details

WithTxn returns errors from transaction begin, commit, and the callback. Only callback errors reached the caller, through a captured outer variable. In OrgBillingRepository.Search the 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)
  • Build and type checking passes

SQL Safety (if your PR touches *_repository.go or goqu.*)

  • Values flow through ? placeholders, goqu.Ex{}, or goqu.Record{} — never fmt.Sprintf or + building a query that gets executed.
  • ToSQL() callers capture and forward params (query, params, err := stmt.ToSQL(); db.…Context(ctx, …, query, params...)). Never query, _, err := ….
  • No ? placeholders inside single-quoted SQL literals in goqu.L (use make_interval(hours => ?)-style functions instead).
  • Any //nolint:forbidigo or // #nosec G20x annotation has a one-line justification on the same line that a reviewer can verify.

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>
@vercel

vercel Bot commented Jul 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
frontier Ready Ready Preview, Comment Jul 17, 2026 9:44am

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@AmanGIT07, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 25 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 449d0f23-6941-4df9-b0f3-d3f50f69358f

📥 Commits

Reviewing files that changed from the base of the PR and between 189c72b and 2dde55c.

📒 Files selected for processing (4)
  • internal/store/postgres/org_billing_repository_test.go
  • internal/store/postgres/org_projects_repository_test.go
  • internal/store/postgres/org_users_repository_test.go
  • internal/store/postgres/project_users_repository_test.go
📝 Walkthrough

Walkthrough

Four PostgreSQL repository Search methods now assign the error returned by WithTxn to the existing err variable. Their existing post-transaction error checks therefore handle both transaction-wrapper failures and errors produced inside the transaction callbacks. No exported declarations or surrounding result transformations changed.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: propagating transaction errors from repository search methods.
Description check ✅ Passed The description follows the template and includes summary, changes, technical details, test plan, and SQL safety items.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coveralls

coveralls commented Jul 17, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 29571017138

Coverage increased (+0.2%) to 46.288%

Details

  • Coverage increased (+0.2%) from the base build.
  • Patch coverage: 4 of 4 lines across 4 files are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 38321
Covered Lines: 17738
Line Coverage: 46.29%
Coverage Strength: 13.34 hits per line

💛 - 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants