-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
still wip: convert seer preferences n+1 query to single query #107276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
still wip: convert seer preferences n+1 query to single query #107276
Conversation
There was a problem hiding this 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 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| status=ObjectStatus.ACTIVE, | ||
| ).count() | ||
| if existing_repos_count != len(all_repos_to_check): | ||
| return Response({"detail": "Invalid repository"}, status=400) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate repos across projects cause false validation failure
High Severity
The validation logic compares existing_repos_count (unique matching database rows) against len(all_repos_to_check) (total input entries including duplicates). When the same repository is mapped to multiple projects, all_repos_to_check contains duplicate tuples, but the database count() only returns unique matches. This causes valid requests to incorrectly fail with "Invalid repository" when the same repo is shared across projects.
Additional Locations (1)
| provider = repo_data["provider"] | ||
| external_id = repo_data["external_id"] | ||
| owner = repo_data["owner"] | ||
| name = repo_data["name"] | ||
| all_repos_to_check.add((provider, external_id, f"{owner}/{name}")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
repo data serialized by
https://github.com/getsentry/sentry/blob/master/src/sentry/seer/endpoints/organization_autofix_automation_settings.py#L50-L54
where all these fields are required
| provider = repo_data["provider"] | ||
| external_id = repo_data["external_id"] | ||
| owner = repo_data["owner"] | ||
| name = repo_data["name"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Serialized by this
https://github.com/getsentry/sentry/blob/master/src/sentry/seer/endpoints/project_seer_preferences.py#L36-L41
where all these fields are required
No description provided.