Skip to content

feat(cells): Add GET path for /organization list on control silo#112622

Merged
lynnagara merged 5 commits intomasterfrom
org-list-control-silo
Apr 14, 2026
Merged

feat(cells): Add GET path for /organization list on control silo#112622
lynnagara merged 5 commits intomasterfrom
org-list-control-silo

Conversation

@lynnagara
Copy link
Copy Markdown
Member

@lynnagara lynnagara commented Apr 9, 2026

  • 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.
  • member sorting functionality (used in _admin) had to be implemented a bit differently since there are no FK relations but works the same

- 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.
@lynnagara lynnagara requested a review from a team April 9, 2026 20:52
@lynnagara lynnagara requested a review from a team as a code owner April 9, 2026 20:52
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 9, 2026
Comment thread src/sentry/core/endpoints/organization_index.py Outdated
Copy link
Copy Markdown
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.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ 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.

Comment thread src/sentry/core/endpoints/organization_index.py Outdated
elif sort_by == "projects":
queryset = queryset.none()
order_by = "-date_created"
paginator_cls = OffsetPaginator
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 4eb4e79. Configure here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

added logging here too

Comment thread src/sentry/core/endpoints/organization_index.py
Comment on lines +177 to +179
# 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.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member Author

@lynnagara lynnagara Apr 13, 2026

Choose a reason for hiding this comment

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

yeah, i'll add one Added logging to sentry

Comment thread src/sentry/core/endpoints/organization_index.py
elif sort_by == "projects":
queryset = queryset.none()
order_by = "-date_created"
paginator_cls = OffsetPaginator
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Comment on lines +320 to +323
elif sort_by == "projects":
queryset = queryset.none()
order_by = "-date_created"
paginator_cls = OffsetPaginator
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I can continue from here with provisioning changes.

@lynnagara lynnagara merged commit 8295fe9 into master Apr 14, 2026
57 checks passed
@lynnagara lynnagara deleted the org-list-control-silo branch April 14, 2026 21:14
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.

2 participants