Skip to content

feat(aci): Track service account and org token creators on detectors - #129550

Merged
DominikB2014 merged 9 commits into
masterfrom
feat/workflow-engine-non-user-creator
Nov 25, 2026
Merged

DominikB2014 merged 9 commits into
masterfrom
feat/workflow-engine-non-user-creator

Conversation

@DominikB2014

@DominikB2014 DominikB2014 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

This adds service account and org auth tokens, so we can track whos created resources. Eventually this will help serve optional guardrails that will allow creators to modify/delete their own resources but not others.

Generated description

Detectors only recorded a user creator, so ones created by service accounts or org auth tokens had no author.

  • Add created_by_service_account_id / created_by_org_auth_token_id to Detector, with an at-most-one-creator check constraint (same as feat(dashboards): Track service account and org token creators #129219 for dashboards).
  • The detector validator uses get_creator_reference(request). The legacy /monitors/ (ensure_cron_detector) and legacy uptime (create_uptime_detector) create paths now record the creator too.

Workflows are in #132450. The two PRs are independent, but both add the next workflow_engine migration, so whichever merges second needs its migration renumbered.

Fixes ENG-8937

via @DominikB2014.

--

View Session [Sentry]

…and workflows

Add created_by_service_account_id and created_by_org_auth_token_id to
Detector and Workflow, with a single-creator check constraint. API create
paths, including legacy cron and uptime monitor creation, now record the
creator via get_creator_reference.

Fixes ENG-8937
@linear-code

linear-code Bot commented Nov 2, 2026

Copy link
Copy Markdown

ENG-8937

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 2, 2026
@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

This PR has a migration; here is the generated SQL for src/sentry/workflow_engine/migrations/0128_add_detector_non_user_creator.py

for 0128_add_detector_non_user_creator in workflow_engine

--
-- Add field created_by_org_auth_token_id to detector
--
ALTER TABLE "workflow_engine_detector" ADD COLUMN "created_by_org_auth_token_id" bigint NULL;
--
-- Add field created_by_service_account_id to detector
--
ALTER TABLE "workflow_engine_detector" ADD COLUMN "created_by_service_account_id" bigint NULL;
--
-- Create constraint workflow_engine_detector_single_creator on model detector
--
ALTER TABLE "workflow_engine_detector" ADD CONSTRAINT "workflow_engine_detector_single_creator" CHECK ((("created_by_service_account_id" IS NULL AND "created_by_org_auth_token_id" IS NULL) OR ("created_by_id" IS NULL AND "created_by_org_auth_token_id" IS NULL) OR ("created_by_id" IS NULL AND "created_by_service_account_id" IS NULL))) NOT VALID;
ALTER TABLE "workflow_engine_detector" VALIDATE CONSTRAINT "workflow_engine_detector_single_creator";
CREATE INDEX CONCURRENTLY "workflow_engine_detector_created_by_org_auth_token_id_14fce493" ON "workflow_engine_detector" ("created_by_org_auth_token_id");
CREATE INDEX CONCURRENTLY "workflow_engine_detector_created_by_service_account_id_8ac26027" ON "workflow_engine_detector" ("created_by_service_account_id");

Tolerate requests without auth in get_creator_reference, allow blank
creator fields on Workflow, and drop org auth token creator references
on relocation import since tokens are imported last.
Move the workflow half into a stacked PR so detectors and workflows
can be reviewed separately.
@DominikB2014 DominikB2014 changed the title feat(aci): Track service account and org token creators on detectors and workflows feat(aci): Track service account and org token creators on detectors Nov 9, 2026
@DominikB2014
DominikB2014 marked this pull request as ready for review November 9, 2026 19:27
@DominikB2014
DominikB2014 requested review from a team as code owners November 9, 2026 19:27
…e-non-user-creator

# Conflicts:
#	migrations_lockfile.txt
#	tests/sentry/workflow_engine/endpoints/test_validators.py
@DominikB2014
DominikB2014 marked this pull request as draft November 12, 2026 17:58
@DominikB2014
DominikB2014 marked this pull request as ready for review November 16, 2026 17:14
DominikB2014 added a commit that referenced this pull request Nov 16, 2026
…rt (#129571)

Follow-up to #129219: org auth tokens are imported last during
relocation, so a dashboard with `created_by_org_auth_token_id` can't be
remapped and is silently dropped.

- `Dashboard.normalize_before_relocation_import` clears
`created_by_org_auth_token_id` so the dashboard imports without that
creator.
- Same override as #129550 (detectors/workflows).

Refs ENG-8934
…130482)

Stacked on #129550 (detectors).

This adds service account and org auth tokens ids, so we can track whos
created resources. Eventually this will help serve optional guardrails
that will allow creators to modify/delete their own resources but not
others.

### Generated description

Workflows only recorded a user creator, so ones created by service
accounts or org auth tokens had no author.
- Add `created_by_service_account_id` / `created_by_org_auth_token_id`
to `Workflow`, with an at-most-one-creator check constraint (same as
#129219 for dashboards).
- The workflow validator records the creator with
`get_creator_reference(request)`.

Refs ENG-8937
@DominikB2014
DominikB2014 requested a review from a team as a code owner November 17, 2026 15:02
…e-non-user-creator

Co-Authored-By: Dominik Buszowiecki <[email protected]>

# Conflicts:
#	migrations_lockfile.txt

@edwardgou-sentry edwardgou-sentry left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

did you want to separate out the pr for the workflow model and the detector model? Looks like theres two migrations and the pr description says Workflows are in a stacked PR on top of this one.

Workflow changes now live in a separate PR stacked on this one.

Co-Authored-By: Dominik Buszowiecki <[email protected]>
@DominikB2014
DominikB2014 merged commit ace6eef into master Nov 25, 2026
106 of 107 checks passed
@DominikB2014
DominikB2014 deleted the feat/workflow-engine-non-user-creator branch November 25, 2026 19:02

This branch was successfully deployed

1 active deployment
Preview — d859d4cb Deployed Nov 25, 2026 by vercel[bot]
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