refactor(frontier): move SearchOrganizationInvoices to FrontierService#476
refactor(frontier): move SearchOrganizationInvoices to FrontierService#476paanSinghCoder wants to merge 1 commit intomainfrom
Conversation
Move the RPC from AdminService to FrontierService so org admins (not only platform superusers) can list their own org's invoices. Also remove the redundant SearchOrganisationInvoices (British spelling) RPC added in #471 which was never implemented on the frontier server. Request/response shape is preserved from the admin version (nested OrganizationInvoice projection + RQLQueryPaginationResponse + RQLQueryGroupResponse). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
The latest Buf updates on your PR. Results from workflow Validate / validate (pull_request).
|
📝 WalkthroughWalkthroughThe changes consolidate invoice search functionality by removing the Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
raystack/frontier/v1beta1/frontier.proto (2)
917-931:OrganizationInvoiceduplicatesSearchInvoicesResponse.Invoicein admin.proto.The nested
OrganizationInvoice(lines 918-926) is field-for-field identical toSearchInvoicesResponse.Invoiceinraystack/frontier/v1beta1/admin.proto(lines ~1556-1565). Since both are nested inside their respective response messages, they generate independent types in downstream code, leading to duplicated models and conversion boilerplate in consumers (frontier Go,@raystack/protonJS, dashboard).Consider promoting a shared top-level
OrganizationInvoicemessage (infrontier.protoormodels.proto) and referencing it from both response messages. This is a non-breaking change for new responses but does reshape the admin response — so it can be deferred until the admin endpoint itself is revisited.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@raystack/frontier/v1beta1/frontier.proto` around lines 917 - 931, The nested message OrganizationInvoice inside SearchOrganizationInvoicesResponse duplicates SearchInvoicesResponse.Invoice from admin.proto; extract OrganizationInvoice to a single shared top-level message (e.g., create a top-level message OrganizationInvoice in frontier.proto or models.proto) and update SearchOrganizationInvoicesResponse.OrganizationInvoice and the admin SearchInvoicesResponse.Invoice to reference that shared top-level OrganizationInvoice instead of declaring a nested type, removing the duplicate nested definition and adjusting any imports/package references accordingly.
912-915: Consider renamingidtoorg_idand tightening validation.The field
idon line 913 semantically represents an organization ID (per PR description and the response'sorg_idprojection), but the nameidis ambiguous in aSearchOrganizationInvoicescontext where an "invoice id" could also be inferred. The adjacentListInvoicesRequest(line 899) usesorg_idwithmin_len = 3, andSearchCurrentUserPATsRequest(line 2559) usesstring.uuid = truefor its org id. Consider either:
- Renaming to
org_idfor consistency withListInvoicesRequestand to disambiguate intent, or- Adding a field comment clarifying that
idis the organization identifier.Additionally, since organization IDs are UUIDs elsewhere in this file (e.g.,
SetOrganizationMemberRoleRequest.org_id,CreateAuditRecordRequest.org_id), consider(buf.validate.field).string.uuid = trueinstead ofmin_len = 3for stricter input validation.📝 Proposed change
message SearchOrganizationInvoicesRequest { - string id = 1 [(buf.validate.field).string.min_len = 3]; + // ID of the organization whose invoices are being searched + string id = 1 [(buf.validate.field).string.min_len = 3]; RQLRequest query = 2; }Or, if the field rename is acceptable (note: this would need to align with the handler/frontend wiring mentioned in the PR description):
message SearchOrganizationInvoicesRequest { - string id = 1 [(buf.validate.field).string.min_len = 3]; + string org_id = 1 [(buf.validate.field).string.min_len = 3]; RQLRequest query = 2; }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@raystack/frontier/v1beta1/frontier.proto` around lines 912 - 915, Rename the ambiguous field id in the proto message SearchOrganizationInvoicesRequest to org_id and tighten its validation to use (buf.validate.field).string.uuid = true to match other org_id fields (e.g., ListInvoicesRequest, SetOrganizationMemberRoleRequest, CreateAuditRecordRequest) and align with SearchCurrentUserPATsRequest usage; update any handler/frontend wiring and all references/imports/generated code that consume SearchOrganizationInvoicesRequest to use the new org_id name and UUID validation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@raystack/frontier/v1beta1/frontier.proto`:
- Around line 917-931: The nested message OrganizationInvoice inside
SearchOrganizationInvoicesResponse duplicates SearchInvoicesResponse.Invoice
from admin.proto; extract OrganizationInvoice to a single shared top-level
message (e.g., create a top-level message OrganizationInvoice in frontier.proto
or models.proto) and update
SearchOrganizationInvoicesResponse.OrganizationInvoice and the admin
SearchInvoicesResponse.Invoice to reference that shared top-level
OrganizationInvoice instead of declaring a nested type, removing the duplicate
nested definition and adjusting any imports/package references accordingly.
- Around line 912-915: Rename the ambiguous field id in the proto message
SearchOrganizationInvoicesRequest to org_id and tighten its validation to use
(buf.validate.field).string.uuid = true to match other org_id fields (e.g.,
ListInvoicesRequest, SetOrganizationMemberRoleRequest, CreateAuditRecordRequest)
and align with SearchCurrentUserPATsRequest usage; update any handler/frontend
wiring and all references/imports/generated code that consume
SearchOrganizationInvoicesRequest to use the new org_id name and UUID
validation.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 13fc14cb-36a7-4f11-a191-a4a295ee7738
📒 Files selected for processing (2)
raystack/frontier/v1beta1/admin.protoraystack/frontier/v1beta1/frontier.proto
💤 Files with no reviewable changes (1)
- raystack/frontier/v1beta1/admin.proto
Move the RPC from AdminService to FrontierService so org admins (not only platform superusers) can list their own org's invoices. Matches the gate pattern already used by FrontierService/ListInvoices (UpdatePermission on the org namespace). Superusers still pass via the standard interceptor bypass. - Bump PROTON_COMMIT to pick up the proto move (raystack/proton#476). - Regenerate proto/v1beta1 via `make proto`. - Swap authorization.go entry from IsSuperUser to IsAuthorized(org, UpdatePermission). - Switch the admin dashboard frontend from AdminServiceQueries to FrontierServiceQueries; request/response shape is unchanged. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary
Follow-up
A corresponding frontier PR will:
Test plan
🤖 Generated with Claude Code