Skip to content

fix(store): org users search reports a value that is not a uuid as bad input - #1942

Merged
AmanGIT07 merged 2 commits into
mainfrom
org-users-invalid-uuid-input
Sep 24, 2026
Merged

AmanGIT07 merged 2 commits into
mainfrom
org-users-invalid-uuid-input

Conversation

@AmanGIT07

Copy link
Copy Markdown
Contributor

Stacked on #1941.

Summary

A role_ids filter value or an org id that is not a uuid made the org users search return an internal error with the raw database message. It now returns invalid argument.

Changes

  • OrgUsersRepository.Search runs the query error through checkPostgresError and returns ErrBadInput for the uuid type error.
  • ExportOrganizationUsers maps ErrBadInput to CodeInvalidArgument, the same as SearchOrganizationUsers already does.
  • New docker-backed case: a non-uuid role id filter and a non-uuid org id both return ErrBadInput.

Technical Details

The filter value and the org id are bound as text against uuid columns, and Postgres raises SQLSTATE 22P02 for a value that does not parse. The request validation only checks that the org id is at least three characters long.

Test Plan

  • go test -run 'TestOrgUsersRepository' ./internal/store/postgres/ passes
  • The new case fails without the change, with invalid input syntax for type uuid in the error chain
  • golangci-lint run on the store and connect packages reports no issues

SQL Safety

  • 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. Never query, _, err := ….
  • No ? placeholders inside single-quoted SQL literals in goqu.L.
  • No new //nolint:forbidigo or // #nosec G20x annotations.

@vercel

vercel Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
frontier Ready Ready Preview Sep 24, 2026 8:00am UTC

@coderabbitai

coderabbitai Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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 configuration

Configuration used: Repository: raystack/frontier/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: c28f45fe-c200-4491-aeb7-080e0f3a8fd9

📥 Commits

Reviewing files that changed from the base of the PR and between 2522d8f and 4fdf9ca.

📒 Files selected for processing (1)
  • internal/api/v1beta1connect/organization_users_test.go

Included review availability: Your plan provides up to 2 included reviews per hour; 0 remain after this review.


📝 Summary

Summary by CodeRabbit

  • Bug Fixes
    • Invalid UUID values in organization-user searches and exports now return an invalid-argument error instead of an internal server error.
    • Malformed organization IDs and role filters are reported as invalid input, with a clearer explanation.
    • Organization-user exports with no data continue to return an invalid-argument error stating that there is no data to export.

Walkthrough

OrgUsersRepository.Search converts invalid UUID errors to postgres.ErrBadInput. ExportOrganizationUsers maps that error to connect.CodeInvalidArgument. Tests cover both mappings and the handler’s existing error responses.

Changes

Organization user UUID errors

Layer / File(s) Summary
Repository UUID error mapping
internal/store/postgres/org_users_repository.go, internal/store/postgres/org_users_repository_pg_test.go
OrgUsersRepository.Search maps invalid PostgreSQL UUID representations to postgres.ErrBadInput. Integration tests cover invalid role_ids values and organization IDs.
Export error response
internal/api/v1beta1connect/organization_users.go, internal/api/v1beta1connect/organization_users_test.go
ExportOrganizationUsers maps postgres.ErrBadInput to connect.CodeInvalidArgument. Tests also cover the no-content and internal-error responses.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: rohilsurana

Merge Risk: ⚪ Minimal · up to 4fdf9

No merge-blocking issue is established for the organization-user UUID error handling. Merge after normal checks.

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
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 Sep 22, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 35972691802

Coverage increased (+0.03%) to 51.676%

Details

  • Coverage increased (+0.03%) from the base build.
  • Patch coverage: 7 of 7 lines across 2 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: 41129
Covered Lines: 21254
Line Coverage: 51.68%
Coverage Strength: 16.85 hits per line

💛 - Coveralls

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: raystack/frontier/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: ca8868a4-d718-4a43-942f-e1bbfe58af99

📥 Commits

Reviewing files that changed from the base of the PR and between 7edb4c6 and fa46090.

📒 Files selected for processing (3)
  • internal/api/v1beta1connect/organization_users.go
  • internal/store/postgres/org_users_repository.go
  • internal/store/postgres/org_users_repository_pg_test.go

Included review availability: Your plan provides up to 2 included reviews per hour; 0 remain after this review.

@AmanGIT07
AmanGIT07 force-pushed the org-users-null-role-filter branch from 7edb4c6 to fa2681c Compare September 24, 2026 05:39
@AmanGIT07
AmanGIT07 force-pushed the org-users-invalid-uuid-input branch from fa46090 to 023ea25 Compare September 24, 2026 05:39
Base automatically changed from org-users-null-role-filter to main September 24, 2026 05:46
…d input

Search maps the database type error to ErrBadInput, so the search and
export handlers answer with invalid argument instead of internal.
Covers the three error paths of ExportOrganizationUsers against the
service mock, so removing the mapping fails a test.
@AmanGIT07
AmanGIT07 merged commit 057a60c into main Sep 24, 2026
10 of 11 checks passed
@AmanGIT07
AmanGIT07 deleted the org-users-invalid-uuid-input branch September 24, 2026 08:10

This branch was successfully deployed

1 active deployment
Preview — 4fdf9ca4 Deployed Sep 24, 2026 by vercel[bot]
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.

3 participants