Repository navigation
feat(service-accounts): Add RPC methods to manage service accounts - #129812
Merged
Merged
Conversation
Cell code can now get, create, update and delete an organization's service accounts through service_account_service. Project-link replacement moves onto ServiceAccount so the endpoint and the RPC share it.
This was referenced Nov 3, 2026
trevor-e
commented
Nov 3, 2026
| raise PermissionDenied(ALL_PROJECTS_ROLE_ERROR) | ||
|
|
||
|
|
||
| def _replace_projects(service_account: ServiceAccount, project_ids: Sequence[int]) -> None: |
The create endpoint and the create_service_account RPC now both call ServiceAccount.create_with_projects. The RPC turns a duplicate-name IntegrityError into an RpcValidationException, so callers get a 422 instead of a 500.
…e-account-rpc # Conflicts: # src/sentry/service_accounts/endpoints/organization_service_accounts.py
Field validators don't run on create or save, so the RPC could store scopes a service account can't hold, like service_account:write. create_with_projects and the update RPC now check scopes against GRANTABLE_SCOPES, and the RPC returns a 422 for a rejected one.
Raise RpcValidationException inline and join all validation messages. Treat any IntegrityError on create as a duplicate name, matching the endpoint.
Only the scope check can now produce an invalid_scope error from create_service_account.
The create RPC catches InvalidScopeError around create_with_projects, so it no longer checks scopes twice and other ValidationErrors aren't reported as invalid_scope.
gricha
approved these changes
Nov 4, 2026
Report duplicate_name only for the name unique constraint and re-raise other integrity errors, such as a missing created_by user. Return the deduplicated project IDs that were stored, document the inputs the RPC doesn't check, and test switching an account to all projects.
Go back to treating any IntegrityError on create as a duplicate name, with a TODO.
trevor-e
marked this pull request as ready for review
November 4, 2026 00:49
trevor-e
added a commit
that referenced
this pull request
Nov 4, 2026
) `PUT` on the Seer workflow configs endpoint now takes `enabled`, so any automation can be turned on or paused after creation. The caller needs access to every project the automation covers. Sending the current value leaves the config version unchanged. An update can now send `enabled` alone instead of requiring `projectIds` or `monitorIds`. Stacked on #129812 for review order only; this PR doesn't depend on it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cell code can now manage an organization's service accounts through
service_account_service, using newget_service_account,create_service_account,update_service_accountanddelete_service_accountRPC methods. Each method is scoped to the organization. Create and update write the account and its project links inside an outbox context, so the cell replica follows. Update returnsNonefor an account outside the organization.The project-link replacement the service-accounts endpoint used moves onto
ServiceAccount.replace_projects, so the endpoint and the RPC share it.These methods have no callers yet. They're split out so control can deploy them before cell code calls them: Seer automations will use them to create and update each automation's own account.