Skip to content

feat(seer): Add new bulk+single Seer project repos endpoints#115199

Draft
srest2021 wants to merge 11 commits into
masterfrom
srest2021/CW-1286
Draft

feat(seer): Add new bulk+single Seer project repos endpoints#115199
srest2021 wants to merge 11 commits into
masterfrom
srest2021/CW-1286

Conversation

@srest2021
Copy link
Copy Markdown
Member

fixes CW-1286

@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 8, 2026

CW-1286

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label May 8, 2026
@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label May 8, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

🚨 Warning: This pull request contains Frontend and Backend changes!

It's discouraged to make changes to Sentry's Frontend and Backend in a single pull request. The Frontend and Backend are not atomically deployed. If the changes are interdependent of each other, they must be separated into two pull requests and be made forward or backwards compatible, such that the Backend or Frontend can be safely deployed independently.

Have questions? Please ask in the #discuss-dev-infra channel.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

📊 Type Coverage Diff

✅ No new type safety issues introduced. Coverage: 93.56%

@srest2021 srest2021 closed this May 8, 2026
@srest2021 srest2021 reopened this May 8, 2026
Comment thread src/sentry/api/urls.py
Comment thread src/sentry/seer/autofix/utils.py Outdated
@getsentry getsentry deleted a comment from github-actions Bot May 19, 2026
Comment on lines +927 to +931
seer_project_repo = SeerProjectRepository.objects.create(
project_repository=project_repo,
branch_name=data.get("branch_name"),
instructions=data.get("instructions"),
)
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.

IntegrityError on duplicate repository_id in replace_all_seer_project_repos

If repos_data contains duplicate repository_id values (not validated by the endpoint), get_or_create returns the same ProjectRepository on the second iteration and SeerProjectRepository.objects.create(project_repository=project_repo) raises an unhandled IntegrityError because SeerProjectRepository.project_repository has unique=True.

Evidence
  • SeerProjectRepository.project_repository is declared unique=True in seer/models/project_repository.py.
  • replace_all_seer_project_repos bulk-deletes existing records then calls SeerProjectRepository.objects.create(project_repository=project_repo, ...) inside a loop.
  • ProjectRepository.objects.get_or_create(project=project, repository_id=data["repository_id"], ...) returns the same project_repo instance for each duplicate entry, so the second create violates the unique constraint.
  • The PUT endpoint validates that all repository_id values belong to the org (via _get_valid_repo_ids) but does not check for duplicates within the submitted list.
  • SeerProjectReposRequestSerializer / SeerProjectRepoSerializer also impose no uniqueness constraint on repository_id across the repos list.
Also found at 2 additional locations
  • src/sentry/seer/endpoints/project_seer_repos.py:195-196
  • src/sentry/seer/endpoints/project_seer_repos.py:270-283

Identified by Warden sentry-backend-bugs · SZM-EAL

@getsentry getsentry deleted a comment from github-actions Bot May 19, 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 Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant