Skip to content

feat(service-accounts): Add RPC methods to manage service accounts - #129812

Merged
trevor-e merged 9 commits into
masterfrom
telkins/seer-service-account-rpc
Nov 4, 2026
Merged

trevor-e merged 9 commits into
masterfrom
telkins/seer-service-account-rpc

Conversation

@trevor-e

@trevor-e trevor-e commented Nov 3, 2026

Copy link
Copy Markdown
Member

Cell code can now manage an organization's service accounts through service_account_service, using new get_service_account, create_service_account, update_service_account and delete_service_account RPC 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 returns None for 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.

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.
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 3, 2026
raise PermissionDenied(ALL_PROJECTS_ROLE_ERROR)


def _replace_projects(service_account: ServiceAccount, project_ids: Sequence[int]) -> None:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Moved

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.
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
trevor-e marked this pull request as ready for review November 4, 2026 00:49
@trevor-e
trevor-e merged commit b7ca7a5 into master Nov 4, 2026
76 checks passed
@trevor-e
trevor-e deleted the telkins/seer-service-account-rpc branch November 4, 2026 00:57
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants