getsentry / getsentry/sentry

Metric monitor shows 'Deactivated user' when created in superuser mode

Open
#117,775 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Product Area: Alerts Waiting for: Product Owner
Dominant language
Python
Stars
44.8k
Forks
4.9k
Avg merge
21h 23m
Merged PRs (30d)
607

Description

Description

When a metric monitor is created in superuser mode on behalf of an organization, the Created By field in the monitor Details panel shows "Deactivated user" instead of an accurate label.

Root Cause

The DetectorExtraDetails.CreatedBy component calls useUserFromId, which fetches the creator via /organizations/{org}/users/{userId}/. This endpoint only returns users who are members of the org. A superuser acting on behalf of an org is not an org member, so the request returns 404 → isError = true → the component renders t('Deactivated user').

The 404 path is intentionally handled as "Deactivated user" (extraDetails.tsx line 76–78), but it conflates two distinct cases:

  • User account is genuinely deactivated or deleted
  • User exists and is active, but is not a member of this org (e.g. a superuser)

Relevant files:

  • static/app/views/detectors/components/details/common/extraDetails.tsx
  • static/app/utils/useUserFromId.tsx
  • src/sentry/incidents/logic.pyuser_id=user.id stored on AlertRuleActivity.CREATED

Impact

Org admins see "Deactivated user" on monitors created on their behalf via superuser, with no indication that the creator was Sentry staff. The label is factually incorrect and likely to cause confusion or false concern about user account health.

Expected Behavior

When /organizations/{org}/users/{userId}/ returns 404, the component should distinguish between a truly deactivated user and a user who simply isn't an org member (e.g. show "Sentry", consistent with the existing null createdBy path, or "Sentry staff").

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in static/app/views/detectors/components/details/common/extraDetails.tsx, especially the CreatedBy rendering around lines 76–78, and trace useUserFromId in static/app/utils/useUserFromId.tsx. Read src/sentry/incidents/logic.py to understand how the creator ID is stored. Done means superuser-created monitors no longer display an inaccurate “Deactivated user” label while genuine deactivated-user handling remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, typescript
Domain
api, backend, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.