Skip to content

Conversation

@mishamo
Copy link

@mishamo mishamo commented Jan 18, 2026

Summary

Adds a new team: search filter that allows filtering issues by the team that owns the project. This addresses #45367.

Usage:

  • team:data-engineering - Issues from projects owned by data-engineering
  • team:#data-engineering - Same (# prefix supported for consistency with other team references)
  • !team:data-engineering - Issues NOT from data-engineering's projects
  • team:[team1,team2] - Issues from projects owned by either team

Changes

  • src/sentry/issues/issue_search.py:
    • Add team key mapping
    • Add convert_team_value() converter that validates teams through projectteam relationship (prevents IDOR by ensuring users can only filter by teams associated with their searched projects)
  • src/sentry/search/snuba/backend.py:
    • Add team_filter() function
    • Add team condition to queryset builder
  • tests/snuba/search/test_backend.py:
    • test_team_filter - Basic filtering with/without # prefix
    • test_team_filter_negation - !team: exclusion
    • test_team_filter_invalid_team - Error handling for non-existent teams
    • test_team_filter_multiple_teams - team:[t1,t2] syntax
    • test_team_filter_team_not_in_searched_projects - Security test for IDOR prevention

Test plan

  • Filter by team slug returns only issues from that team's projects
  • # prefix works for consistency with other team references
  • Negation (!team:) excludes issues from team's projects
  • Invalid team raises InvalidSearchQuery
  • Multiple teams syntax works
  • Teams not associated with searched projects raise error (IDOR prevention)

🤖 Generated with Claude Code

@mishamo mishamo requested review from a team as code owners January 18, 2026 12:55
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jan 18, 2026
@mishamo mishamo requested a review from a team as a code owner January 18, 2026 16:22
Adds a new `team:` search filter that allows filtering issues by the team
that owns the project. This addresses GitHub issue getsentry#45367.

Usage:
- `team:data-engineering` - Issues from projects owned by data-engineering
- `team:#data-engineering` - Same (# prefix supported for consistency)
- `!team:data-engineering` - Issues NOT from data-engineering's projects
- `team:[team1,team2]` - Issues from projects owned by either team

Changes:
- Add team key mapping and convert_team_value() in issue_search.py
- Add team_filter() function and condition in backend.py
- Add 'team' to NO_CONVERSION_FIELDS to skip Snuba conversion
- Add comprehensive tests for team filter functionality

Security:
- Filter teams through projectteam relationship to prevent IDOR
- Users can only filter by teams associated with their searched projects

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@mishamo mishamo force-pushed the feat/team-issue-filter branch from 5aba036 to 81d8ffc Compare January 18, 2026 17:27
@mishamo
Copy link
Author

mishamo commented Jan 18, 2026

bugbot review

@mishamo
Copy link
Author

mishamo commented Jan 18, 2026

@sentry review

Copy link
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no bugs!

@mishamo
Copy link
Author

mishamo commented Jan 19, 2026

Is there anything else I have to do in the PR process here? (I can't find any docs). Or is this just waiting for a maintainer to take a look?

@cvxluo
Copy link
Contributor

cvxluo commented Jan 20, 2026

Is there anything else I have to do in the PR process here? (I can't find any docs). Or is this just waiting for a maintainer to take a look?

you're all good, i'll take a look.

@cvxluo cvxluo added the Trigger: getsentry tests Once code is reviewed: apply label to PR to trigger getsentry tests label Jan 20, 2026
@scttcper
Copy link
Member

this likely would need to take into account the org open membership settings

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 Trigger: getsentry tests Once code is reviewed: apply label to PR to trigger getsentry tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants