Conversation
Every aggregate search runs its query error through checkPostgresError and answers ErrBadInput when the database could not read a value as a uuid. The organizations search handler gains the branch the others already had.
…d input One case per search against postgres, plus handler cases for the organizations search error mapping.
|
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 (14)
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review. 📝 SummarySummary by CodeRabbit
WalkthroughSearch repositories now map PostgreSQL invalid UUID errors to ChangesInvalid UUID search handling
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to Malformed UUID searches receive the intended bad-input response. No actionable issue remains before merge, subject to normal checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to Malformed identifiers now receive an invalid-input response instead of an internal-error response. The reviewed paths show no new data access or privilege, but the assessment does not cover every caller or deployment control. 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 36130478918Warning 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.4%) to 52.47%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
Follows #1942, which fixed this for the organization users search. This applies the same treatment to the rest.
Summary
Every aggregate search binds a caller supplied id to a uuid column. A value the database cannot read as a uuid reached the handler as a raw driver error, so the API answered internal and echoed the database text. It now answers invalid argument.
Changes
checkPostgresErrorand returnErrBadInputforErrInvalidTextRepresentation, matching the shape already used in the audit repositories. Searches that wrap their error keep their own wording in the default branch.ErrBadInputbranch. The other ten handlers already had it, because repositories already answerErrBadInputfor an unsupported filter or sort.org_users_repository.gomoves from the inlineifadded in fix(store): org users search reports a value that is not a uuid as bad input #1942 to the same switch, so all eleven read alike.search_invalid_uuid_pg_test.go: one case per search against a real postgres. Neworganization_billing_test.go: handler cases for the mapping above.Technical Details
checkPostgresErroris not automatic, it is a function each caller invokes. None of these searches called it, so the driver error travelled untouched to the handler anderrors.Is(err, ErrInvalidTextRepresentation)was false everywhere.The mapping sits after the transaction rather than inside its closure, so it does not depend on how the transaction wrapper reports a rollback.
The organizations search takes no id. Its bad value arrives through the
idfilter, which compares against the organizations primary key.Test Plan
go test ./internal/store/postgres/ ./internal/api/v1beta1connect/passesmainfor ten of the eleven searches; organization users already passed there because of fix(store): org users search reports a value that is not a uuid as bad input #1942golangci-lint runon both packages reports no issuesmainand this branch on the same database with only the binary swappedSearchOrganizationProjectsSearchOrganizationServiceUserCredentialsSearchProjectUsersSearchOrganizationsSearchOrganizationUsersSearchOrganizationPATsSearchUserOrganizationsSearchUserProjectsSearchOrganizationServiceUsersSearchOrganizationInvoicesSearchOrganizationTokensFour RPCs change. Of the rest, organization PATs, user organizations and user projects validate the id as a uuid in proto so the request stops earlier, and organization service users, invoices and tokens resolve the organization before the search and answer not found. Their repositories are still covered, because the same path is reachable through a filter value.
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.