Skip to content

Conversation

@seer-by-sentry
Copy link
Contributor

This PR fixes an IndexError: list index out of range that occurred in sentry/search/utils.py:get_teams_for_users.

Root Cause

The function attempts to access projects[0].organization_id to determine the organization context for querying OrganizationMember and OrganizationMemberTeam.

If the projects list passed to this utility function is empty (which can happen when filtering the Detector API index endpoint if the user has no accessible projects or no projects match the initial filters), the list access fails.

Fix

Added an early return check at the beginning of get_teams_for_users to return an empty list if projects is empty, ensuring the function handles this valid edge case gracefully.

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Dec 18, 2025
@codecov
Copy link

codecov bot commented Dec 18, 2025

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/sentry/search/utils.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master   #105259      +/-   ##
===========================================
+ Coverage   74.68%    80.58%   +5.90%     
===========================================
  Files        9435      9438       +3     
  Lines      404492    404532      +40     
  Branches    25703     25703              
===========================================
+ Hits       302079    325994   +23915     
+ Misses     101945     78070   -23875     
  Partials      468       468              

@getsantry
Copy link
Contributor

getsantry bot commented Jan 9, 2026

This pull request has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you add the label WIP, I will leave it alone unless WIP is removed ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@getsantry getsantry bot added the Stale label Jan 9, 2026
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 Stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant