perf(api): Add collapse=organization to project details endpoint#113140
Open
perf(api): Add collapse=organization to project details endpoint#113140
Conversation
The project details endpoint serializes the full organization through OrganizationSummarySerializer which fetches avatars, auth provider config, and computes feature flags. When the caller only needs the org id and slug, `?collapse=organization` skips all of that and returns a minimal object. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
JoshFerge
approved these changes
Apr 15, 2026
Comment on lines
+983
to
+992
| if self._collapse(ORGANIZATION_KEY): | ||
| orgs = { | ||
| str(i.organization_id): { | ||
| "id": str(i.organization_id), | ||
| "slug": i.organization.slug, | ||
| } | ||
| for i in item_list | ||
| } | ||
| else: | ||
| orgs = {d["id"]: d for d in serialize(list({i.organization for i in item_list}), user)} |
Contributor
There was a problem hiding this comment.
Bug: The collapse=organization parameter returns a minimal object instead of omitting the organization key, which is inconsistent with other collapse parameters in the API.
Severity: LOW
Suggested Fix
To ensure API consistency, modify the serializer to completely omit the organization field from the response when collapse=organization is specified, matching the behavior of other collapse parameters.
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/api/serializers/models/project.py#L983-L992
Potential issue: The handling of `collapse=organization` in the
`DetailedProjectSerializer` is inconsistent with other `collapse` parameters in the API.
While other parameters like `latestDeploys` cause the corresponding key to be omitted
from the response, `collapse=organization` results in the `organization` key being
present but with a minimal object containing only `id` and `slug`. This violates the
established pattern for this feature, creating a semantic inconsistency. A client
expecting the key to be absent when collapsed, based on behavior elsewhere, may function
incorrectly.
Did we get this right? 👍 / 👎 to inform future reviews.
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.
The project details endpoint serializes the full organization through OrganizationSummarySerializer which fetches avatars, auth provider config, and computes feature flags. When the caller only needs the org id and slug,
?collapse=organizationskips all of that and returns a minimal object.Could shave off 400ms of the current project details 500ms request time.