Skip to content

ref(typing): Let issue search take a service account - #129609

Merged
gricha merged 1 commit into
fix/detector-my-teams-no-teamsfrom
ref/sa-issue-search
Nov 4, 2026
Merged

gricha merged 1 commit into
fix/detector-my-teams-no-teamsfrom
ref/sa-issue-search

Conversation

@gricha

@gricha gricha commented Nov 2, 2026

Copy link
Copy Markdown
Member

Let the issue search helpers take any RequestPrincipal, which drops 5 files (6 errors) from the request.user mypy allowlist (22 → 17).

Type-only, with one runtime change for service accounts: get_teams_for_users now skips callers with no user (has_user) instead of reading .id.

Caller assigned:my_teams before After
user their teams same
API key / anonymous no teams (user_id IN (NULL)) no teams (user_id IN ())
service account 403 user-required no teams, empty result

assigned:me already resolved to "nobody" for every caller without a user (parse_user_value), so a service account now gets the same answer for both.

test_service_account_has_no_teams_or_self_to_search_by fails without this change:

E   AssertionError: b'{"detail":{"code":"user-required","message":"This action requires a user.","extra":{}}}'
E   assert 403 == 200

Files leaving the allowlist: organization_issues_count.py, group_events.py, group_event_details.py, api/helpers/group_index/index.py, organization_detector_index.py.

Known gap, not changed here: record_advanced_search_feature_gated records a service account's ServiceAccountId as the analytics user_id; it's an untyped signal receiver, so the plugin doesn't see it.

@gricha
gricha added this pull request to stack #129572 November 2, 2026 23:42
@gricha
gricha requested review from a team as code owners November 2, 2026 23:42
@gricha
gricha requested review from azulus, cvxluo and skaasten November 2, 2026 23:42
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 2, 2026
@gricha
gricha force-pushed the ref/sa-issue-search branch from 37b0910 to 07a2de4 Compare November 3, 2026 00:27
@gricha
gricha force-pushed the ref/sa-issue-search branch from 07a2de4 to 5928109 Compare November 3, 2026 00:34
@sentry

sentry Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Sentry Snapshot Testing

Name Added Removed Changed Renamed Unchanged Skipped Status
sentry-frontend
sentry-frontend
0 0 0 0 780 0 ✅ Unchanged

⚙️ sentry-frontend Snapshot Settings

@gricha
gricha force-pushed the ref/sa-issue-search branch 2 times, most recently from edb5caf to f492b6e Compare November 3, 2026 04:41
@gricha
gricha removed this pull request from stack #129572 November 3, 2026 06:52
@gricha
gricha added this pull request to stack #129650 November 3, 2026 06:52
@gricha
gricha force-pushed the ref/sa-issue-search branch from f492b6e to c0e1844 Compare November 3, 2026 19:53
@gricha
gricha removed this pull request from stack #129650 November 3, 2026 19:53
@gricha
gricha added this pull request to stack #129747 November 3, 2026 19:54
@gricha
gricha requested review from a team as code owners November 3, 2026 20:01
@gricha
gricha requested review from a team as code owners November 3, 2026 20:01
@gricha
gricha force-pushed the ref/sa-issue-search branch from c0e1844 to 57a3a03 Compare November 3, 2026 20:01
@gricha
gricha force-pushed the ref/sa-issue-search branch from 57a3a03 to 1006728 Compare November 3, 2026 20:09
@gricha
gricha force-pushed the ref/sa-issue-search branch 2 times, most recently from a4ccf2a to 2234f4f Compare November 3, 2026 21:10
@gricha
gricha force-pushed the ref/sa-issue-search branch from 2234f4f to 43dc84a Compare November 3, 2026 23:19
Type the issue search helpers with RequestPrincipal, dropping five files
from the request.user allowlist. get_teams_for_users skips callers with
no user, so a service account searching assigned:my_teams matches no
teams instead of failing with 403.
@gricha
gricha force-pushed the ref/sa-issue-search branch from 43dc84a to cf654d3 Compare November 4, 2026 00:44
@gricha
gricha merged commit 395dd45 into master Nov 4, 2026
127 of 179 checks passed
@gricha
gricha deleted the ref/sa-issue-search branch November 4, 2026 01:15
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.

4 participants