Skip to content

feat(frontier): add AddOrganizationMembers RPC#469

Open
whoAbhishekSah wants to merge 2 commits intomainfrom
feat/add-organization-member-rpc
Open

feat(frontier): add AddOrganizationMembers RPC#469
whoAbhishekSah wants to merge 2 commits intomainfrom
feat/add-organization-member-rpc

Conversation

@whoAbhishekSah
Copy link
Copy Markdown
Member

@whoAbhishekSah whoAbhishekSah commented Apr 9, 2026

Summary

  • Add AddOrganizationMembers RPC that accepts a list of {user_id, role_id} pairs with UUID validation
  • Returns per-member {user_id, success, error} results for partial failure handling
  • Intended to eventually replace AddOrganizationUsers which lacks a role parameter and hardcodes the default viewer role

Example

Request

{
  "org_id": "a9a62b93-ae6f-4aba-9c32-73281c49da73",
  "members": [
    {
      "user_id": "998d7ebe-cd2c-4f0c-a560-7dd2a7d1a62c",
      "role_id": "e57e1ba4-21fd-43a4-8aca-aa560afb32cf"
    },
    {
      "user_id": "6a51c542-7ca9-4b23-8709-74145013d919",
      "role_id": "afe94f10-1508-4379-88b1-2c328cb2b769"
    }
  ]
}

Response

{
  "results": [
    {
      "user_id": "998d7ebe-cd2c-4f0c-a560-7dd2a7d1a62c",
      "success": true,
      "error": ""
    },
    {
      "user_id": "6a51c542-7ca9-4b23-8709-74145013d919",
      "success": false,
      "error": "principal is already a member of this resource"
    }
  ]
}

🤖 Generated with Claude Code

…xplicit roles

AddOrganizationUsers lacks a role parameter and hardcodes the default
viewer role. AddOrganizationMembers accepts a list of {user_id, role_id}
pairs so callers can specify the role at add time. Returns per-member
success/error results for partial failure handling.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 9, 2026

The latest Buf updates on your PR. Results from workflow Validate / validate (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed⏩ skipped✅ passed✅ passedApr 9, 2026, 5:19 AM

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 9, 2026

Warning

Rate limit exceeded

@whoAbhishekSah has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 12 minutes and 16 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 12 minutes and 16 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c0dca28c-affc-4aba-84cf-a0a05d7f3f70

📥 Commits

Reviewing files that changed from the base of the PR and between 35e0852 and f7c40ab.

📒 Files selected for processing (1)
  • raystack/frontier/v1beta1/admin.proto
📝 Walkthrough

Walkthrough

The pull request adds a new RPC method AddOrganizationMembers to the FrontierService in the protobuf definition. This method enables bulk role assignment for organization members by accepting an organization ID and a list of member entries, each specifying a user ID and role ID. The response provides individual results for each member operation, indicating success or failure status. The existing SetOrganizationMemberRole RPC remains unchanged.

Suggested reviewers

  • rsbh
  • AmanGIT07
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The pull request description clearly outlines the purpose, implementation details, and intent of the AddOrganizationMembers RPC with concrete request/response examples.
Title check ✅ Passed The pull request title accurately describes the main change: adding a new AddOrganizationMembers RPC to the FrontierService.

✏️ 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.

❤️ Share

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

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@raystack/frontier/v1beta1/frontier.proto`:
- Around line 1616-1620: OrgMemberResult is ambiguous because requests are keyed
by {user_id, role_id} but the response only returns user_id; update the response
shape to include the role identifier so results can be correlated to the
original request entries. Modify the OrgMemberResult message (e.g., add a string
role_id field or an index field) and ensure any code that constructs
OrgMemberResult (handlers that populate OrgMemberResult) sets this new field so
clients can reliably map success/error back to the specific {user_id, role_id}
pair.
- Around line 1602-1605: The AddOrganizationMembersRequest message's members
field currently allows empty and unbounded lists—add Buf validation constraints
to enforce a minimum of 1 item and a bounded maximum; update the members field
(in the AddOrganizationMembersRequest message) to include
(buf.validate.field).repeated.min_items = 1 and set
(buf.validate.field).repeated.max_items = 10 (or change to 20 if the team agrees
on a larger batch size) so it matches other bulk operation patterns—confirm the
final max_items with the team and apply that value.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8e72736a-3b52-49de-ba1f-b774f5f06c1b

📥 Commits

Reviewing files that changed from the base of the PR and between ac2df19 and 35e0852.

📒 Files selected for processing (1)
  • raystack/frontier/v1beta1/frontier.proto

Comment on lines +1602 to +1605
message AddOrganizationMembersRequest {
string org_id = 1 [(buf.validate.field).string.uuid = true];
repeated OrgMemberEntry members = 2;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
rg -n --type=proto '\(buf\.validate\.field\)\.repeated\s*=\s*\{' raystack/frontier/v1beta1/frontier.proto -C2

Repository: raystack/proton

Length of output: 88


🏁 Script executed:

# Read the actual code at the specified lines
cat -n raystack/frontier/v1beta1/frontier.proto | sed -n '1600,1615p'

Repository: raystack/proton

Length of output: 601


🏁 Script executed:

# Search for repeated field validation patterns in proto files (no -t filter)
rg -n 'repeated.*\(buf\.validate\.field\)' raystack/frontier/v1beta1/frontier.proto -A2

Repository: raystack/proton

Length of output: 750


🏁 Script executed:

# Search for max_items and min_items patterns in the proto file
rg -n '(min_items|max_items)' raystack/frontier/v1beta1/frontier.proto -B2 -A2

Repository: raystack/proton

Length of output: 1923


🏁 Script executed:

# Look for similar bulk operation patterns (e.g., AddOrganization* or *MembersRequest)
rg -n 'repeated.*Entry|repeated.*Request' raystack/frontier/v1beta1/frontier.proto | head -30

Repository: raystack/proton

Length of output: 582


Add cardinality constraints to members field.

Line 1604 currently allows empty and unbounded member lists. The codebase enforces min_items: 1 on all similar bulk operations (e.g., BatchCheckPermissionRequest, PreferenceRequestBody patterns). Add the same constraint here.

For max_items, existing patterns show 20 (permission checks) or 10 (other operations). Confirm the appropriate max batch size with the team, then apply the constraint.

Proposed contract update
 message AddOrganizationMembersRequest {
   string org_id = 1 [(buf.validate.field).string.uuid = true];
-  repeated OrgMemberEntry members = 2;
+  repeated OrgMemberEntry members = 2 [(buf.validate.field).repeated = {
+    min_items: 1
+    max_items: <confirm with team>
+  }];
 }
🤖 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 1602 - 1605, The
AddOrganizationMembersRequest message's members field currently allows empty and
unbounded lists—add Buf validation constraints to enforce a minimum of 1 item
and a bounded maximum; update the members field (in the
AddOrganizationMembersRequest message) to include
(buf.validate.field).repeated.min_items = 1 and set
(buf.validate.field).repeated.max_items = 10 (or change to 20 if the team agrees
on a larger batch size) so it matches other bulk operation patterns—confirm the
final max_items with the team and apply that value.

@whoAbhishekSah whoAbhishekSah changed the title feat: add AddOrganizationMembers RPC feat(frontier): add AddOrganizationMembers RPC Apr 9, 2026
This is a superadmin-only operation. Move from FrontierService to
AdminService where authorization checks IsSuperUser.

Co-Authored-By: Claude Opus 4.6 (1M context) <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.

1 participant