feat(cells): Add GET path for /organization list on control silo#112622
feat(cells): Add GET path for /organization list on control silo#112622
Conversation
- org listing needs to move to the control silo as it returns data relating to orgs that can be spread across multiple cells - this change introduces the new path, while keeping the existing cell-based org listing in place - the new implementation uses the control silo variants `OrganizationMapping` and `OrganizationMemberMapping` in place of Organization and `OrganizationMember` - `owner=1` is not supported currently. This is used for account closing and can be moved to a separate (control-based) api - platform filtering exists on the cell but is not ported to control - this appears to be older, unused functionality and is not worth porting since this information is not be available in control - added a TODO for avatar functionality: this should also be available in the control endpoint, but we need to sync avatars to control as a prerequisite. This will be tackled separately.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 4eb4e79. Configure here.
| elif sort_by == "projects": | ||
| queryset = queryset.none() | ||
| order_by = "-date_created" | ||
| paginator_cls = OffsetPaginator |
There was a problem hiding this comment.
Sorting by projects silently returns empty results
Medium Severity
When sortBy=projects is requested on the control silo, queryset.none() silently drops all organizations and returns an empty list. This is a documented public API parameter (see OrganizationParams.SORT_BY), so callers will see zero results with no error indication. This is inconsistent with the owner=1 handling, which properly returns HTTP 400 with a descriptive message. A user or frontend sorting by projects would see no organizations listed at all.
Reviewed by Cursor Bugbot for commit 4eb4e79. Configure here.
There was a problem hiding this comment.
Should we raise an error here instead of silently returning no records? This is another filter option that we should collect metrics from to gauge whether or not we'll need to find a solution to make it work in the control based implementation.
There was a problem hiding this comment.
added logging here too
| # Note: platform filtering is kept here but is not present in the control version | ||
| # of this endpoint, since the data is not in control and our UI isn't | ||
| # passing this anymore. |
There was a problem hiding this comment.
Should we add a metric/log here to see if customers are actively using this filter? If, this filter gets high usage, we'll need to find a solution for it when we move GET /organizations to control.
There was a problem hiding this comment.
yeah, i'll add one Added logging to sentry
| elif sort_by == "projects": | ||
| queryset = queryset.none() | ||
| order_by = "-date_created" | ||
| paginator_cls = OffsetPaginator |
There was a problem hiding this comment.
Should we raise an error here instead of silently returning no records? This is another filter option that we should collect metrics from to gauge whether or not we'll need to find a solution to make it work in the control based implementation.
| elif sort_by == "projects": | ||
| queryset = queryset.none() | ||
| order_by = "-date_created" | ||
| paginator_cls = OffsetPaginator |
There was a problem hiding this comment.
Bug: When sorting by projects in the control silo, the queryset is unconditionally cleared with queryset.none(), causing the endpoint to silently return an empty list.
Severity: MEDIUM
Suggested Fix
The logic for handling sorting by projects in the control silo should be implemented correctly instead of calling queryset.none(). This likely involves adding the appropriate annotation and ordering to the queryset, similar to how other sort fields are handled.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: src/sentry/core/endpoints/organization_index.py#L320-L323
Potential issue: When sorting by `projects` in the control silo, the queryset is
unconditionally cleared by calling `queryset.none()`. This causes the endpoint to
silently return an empty list of organizations instead of a sorted list. Any clients or
admin tools that attempt to sort organizations by their project count will receive no
results, without any error or warning indicating that the operation failed.
There was a problem hiding this comment.
Added logging on the existing cell silo paths. I think this is fine for now since it's unused - will decide the path forward here after collecting logs for a few days.
| # legacy cell-side path can be removed once the control implementation | ||
| # is ready. | ||
| if SiloMode.get_current_mode() == SiloMode.CONTROL: | ||
| return Response(status=404) |
There was a problem hiding this comment.
I can continue from here with provisioning changes.


OrganizationMappingandOrganizationMemberMappingin place of Organization andOrganizationMemberowner=1is not supported currently. This is used for account closing and can be moved to a separate (control-based) api