feat(seer): Add new bulk+single Seer project repos endpoints#115199
feat(seer): Add new bulk+single Seer project repos endpoints#115199srest2021 wants to merge 11 commits into
Conversation
|
🚨 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 |
📊 Type Coverage Diff✅ No new type safety issues introduced. Coverage: 93.56% |
| seer_project_repo = SeerProjectRepository.objects.create( | ||
| project_repository=project_repo, | ||
| branch_name=data.get("branch_name"), | ||
| instructions=data.get("instructions"), | ||
| ) |
There was a problem hiding this comment.
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_repositoryis declaredunique=Trueinseer/models/project_repository.py.replace_all_seer_project_reposbulk-deletes existing records then callsSeerProjectRepository.objects.create(project_repository=project_repo, ...)inside a loop.ProjectRepository.objects.get_or_create(project=project, repository_id=data["repository_id"], ...)returns the sameproject_repoinstance for each duplicate entry, so the secondcreateviolates the unique constraint.- The PUT endpoint validates that all
repository_idvalues belong to the org (via_get_valid_repo_ids) but does not check for duplicates within the submitted list. SeerProjectReposRequestSerializer/SeerProjectRepoSerializeralso impose no uniqueness constraint onrepository_idacross thereposlist.
Also found at 2 additional locations
src/sentry/seer/endpoints/project_seer_repos.py:195-196src/sentry/seer/endpoints/project_seer_repos.py:270-283
Identified by Warden sentry-backend-bugs · SZM-EAL
fixes CW-1286