Repository navigation
fix(issues): Match no issues for my_teams when the caller has no teams - #129424
Merged
Merged
Conversation
An empty my_teams list made assigned_to_filter and assigned_or_suggested_filter return an empty Q(), and the inbox sort skipped its owner filter, so the search matched every issue. Return Q(pk__in=[]) for an empty list instead.
This was referenced Nov 1, 2026
gricha
marked this pull request as ready for review
November 2, 2026 18:55
skaasten
approved these changes
Nov 2, 2026
cvxluo
approved these changes
Nov 2, 2026
gricha
added a commit
that referenced
this pull request
Nov 3, 2026
… has no teams assignee:my_teams ORed nothing onto Q() for a caller on no teams, and filter(Q()) matches every detector. Return Q(pk__in=[]) instead, as #129424 did for issue search.
gricha
added a commit
that referenced
this pull request
Nov 3, 2026
Issue endpoints (hashes, similar issues, notes, issue views, supergroups, release commits) read the caller through `sentry.auth.principal`; personal issue-view writes use `require_user()`. - A service account can unmerge (was a 500: `ServiceAccountId` isn't serializable) and gets 404 editing notes it doesn't own; posting a note and saving issue views stay 403 `user-required` by design. Seer no longer receives a service-account id as the user. New tests cover unmerge and notes. - Legacy API keys get 401 instead of a 500 on starred issue views. - Users and agents see no change. Left on #129402's mypy allowlist: issue search (`convert_query_values`, `parse_query`, `validate_search_filter_permissions`). Passing no user there makes `assigned:my_teams` resolve to an empty team list, and `assigned_to_filter([])` matches every issue: an existing bug for users with no teams and API keys, fixed in #129424. Also `get_create_issue_config` in `group_integration_details.py`.
gricha
added a commit
that referenced
this pull request
Nov 3, 2026
…list (#129402) mypy now types DRF `request.user` as `User | AnonymousUser | ServiceAccountPrincipal`, except in files on `tools/mypy_helpers/request_user_allowlist.txt`. Those keep today's type, so mypy stays green, while every other file must narrow before it reads user-only attributes. - **Plugin:** an attribute hook on `rest_framework.request.Request.user` returns the union outside the allowlist. `report_config_data` rechecks a cached module when it joins or leaves the list; the list is re-read when the file changes, so a running `dmypy` uses the current list for any file it rechecks. dmypy doesn't recheck an unchanged file just because it joined or left the list; touch the file or restart the daemon. - **Sentry only:** files outside this repo keep today's type. getsentry loads this plugin through a `tools -> ../sentry/tools` symlink, and without this its typing job failed with 10 errors in 5 files. `test_drf_request_user_keeps_its_type_outside_sentry` runs mypy the way getsentry does. - **`ServiceAccountPrincipal.id`** is hidden from mypy (`if not TYPE_CHECKING`) but kept at runtime, so `ServiceAccountId` still guards unconverted reads. - **Allowlist:** 23 files, exactly the ones with errors once the PRs below land (31 errors): member management (4), issue search (5, after #129424), `features.batch_has` (3) and 11 one-offs. A test fails if the list grows or names a deleted file, and another fails if the hook stops applying. - **AGENTS.md:** a two-line note that fixing a file means removing it from the list. No runtime change. It lands after the fixes: the PRs below narrow the rest, and each later fix removes its files from the list.
gricha
added a commit
that referenced
this pull request
Nov 4, 2026
… has no teams (#129608) `assignee:my_teams` on the detector list returned every detector when the caller is on no teams. `convert_assignee_values` ORs one `Q` per resolved actor onto an empty `Q()`. `my_teams` resolves to no actors for a member with no teams, so the result stays `Q()`, and `filter(Q())` matches every row. #129424 fixed the same thing for issue search; this does it for detectors. Negation is unchanged: `exclude(Q(pk__in=[]))` still keeps every row. The test checks `!assignee:my_teams` still returns all three detectors. `test_query_by_assignee_my_teams_without_teams` fails without the fix, returning all 3 detectors (one owned by a team the caller isn't on, two unowned): ``` E AssertionError: assert [{'id': '1', ...': None, ...}] == [] E Left contains 3 more items, first extra item: {'id': '1', ..., 'name': 'Error Monitor', ...} FAILED tests/sentry/workflow_engine/endpoints/test_organization_detector_index.py::OrganizationDetectorIndexGetTest::test_query_by_assignee_my_teams_without_teams ``` With it, the file passes: `102 passed, 7 subtests passed`. An empty `values` list (not reachable from the endpoint) now matches nothing instead of everything; its unit test is updated.
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.
assigned:my_teamsandassigned_or_suggested:my_teamsmatched every issue when the caller belongs to no teams.my_teamsresolves to the caller's teams. With none, the list is empty:assigned_to_filter([])andassigned_or_suggested_filter([])returned an emptyQ(), which filters nothing. The inbox sort had the same gap:if owner_search:skipped the owner filter on an empty list.Both filters now return
Q(pk__in=[])for an empty list, so the search matches nothing.!assigned:my_teamsstill matches everything, since excluding nothing keeps every row. Lists with at least one actor build the same query as before.Who hit this: members with no teams, and API key / org token callers. They have no user, so
get_teams_for_usersreturns no teams.Found while narrowing
request.userfor service accounts, which have no teams either.Evidence:
test_my_teams_without_teams_matches_nothing(search backend) andtest_sort_by_inbox_my_teams_without_teams(inbox sort) fail on master:and pass with the fix: