-
Notifications
You must be signed in to change notification settings - Fork 186
Add batch of members endpoints to fix race conditions (#2760) #2779
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add batch of members endpoints to fix race conditions (#2760) #2779
Conversation
Why not allow adding/removing a batch of users? |
5aa6f22
to
95d076d
Compare
One more thought: One this is done, we can also add UI via a separate PR. |
e89a648
to
146cce7
Compare
f00e467
to
5ca77f9
Compare
437899b
to
806c095
Compare
Is this PR a part of #2795? If so, should it be closed? |
948c5e4
to
f15435f
Compare
f15435f
to
2d5ce9e
Compare
@r4victor please confirm if this is good to merge |
@haydnli-shopify Since we merged #2795, this PR can be closed, right? |
Yes, i will close it! |
Summary
Implements atomic single and batch member management endpoints to eliminate race conditions when multiple automations add/remove project members simultaneously. The existing
set_members
endpoint required passing an authoritative list of all members, creating race conditions in concurrent scenarios.This PR enhances the member management system to support both single-user and batch operations through the same endpoints, providing flexibility for different use cases while maintaining backwards compatibility.
Fixes #2684 (parent ticket #2742)
Changes Made
AddProjectMemberRequest
to accept single member or array of membersRemoveProjectMemberRequest
to accept single username or array of usernamesadd_project_members()
andremove_project_members()
service functions supporting both single and batch operationsPOST /api/projects/{project_name}/add_member
endpoint for single/batch operationsPOST /api/projects/{project_name}/remove_member
endpoint for single/batch operationsProjectsAPIClient
with backwards-compatible methods and new batch methodsAPI Usage
Add a single member
POST /api/projects/my-project/add_member
Body:
Add multiple members (batch)
POST /api/projects/my-project/add_member
Body:
Remove a single member
POST /api/projects/my-project/remove_member
Body:
Remove multiple members (batch)
POST /api/projects/my-project/remove_member
Body:
Update existing member role (via add_member)
POST /api/projects/my-project/add_member
Body:
Race Condition Fix
Previously, concurrent automations had to read and rewrite the entire project member list using the
set_members
endpoint, which led to race conditions and unintended overwrites. This PR introduces atomicadd_member
andremove_member
operations that support both single and batch operations, allowing changes to apply independently and safely—even when triggered simultaneously.