Skip to content

feat(repositories): Add project repo-link endpoint#115754

Merged
wedamija merged 2 commits into
masterfrom
danf/project-repo-link-endpoint
May 19, 2026
Merged

feat(repositories): Add project repo-link endpoint#115754
wedamija merged 2 commits into
masterfrom
danf/project-repo-link-endpoint

Conversation

@wedamija
Copy link
Copy Markdown
Member

Summary

Adds POST /api/0/projects/{org}/{project}/repo-link/ to create a ProjectRepository link between a project and an existing repository.

Used by the SCM onboarding flow to persist the user's repo selection after project creation. The frontend PR to call this endpoint will follow.

  • Accepts {"repositoryId": <int>}
  • Creates ProjectRepository with source=SCM_ONBOARDING
  • Idempotent: returns 200 if the link already exists, 201 if created
  • Scopes the repo lookup to the project's organization (IDOR prevention)

Test plan

  • test_creates_link — creates ProjectRepository with correct source
  • test_idempotent — returns 200 without duplicating
  • test_repo_not_found — 404 for nonexistent repo
  • test_repo_from_other_org — 404 for repo in different org
  • test_inactive_repo — 404 for hidden/disabled repo
  • test_missing_repository_id — 400 for missing field

@wedamija wedamija requested review from a team as code owners May 18, 2026 21:05
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label May 18, 2026
@getsantry getsantry Bot requested a review from a team as a code owner May 18, 2026 21:07
@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label May 18, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🚨 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 18, 2026

📊 Type Coverage Diff

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

@wedamija wedamija force-pushed the danf/project-repo-link-endpoint branch from b2c1c1e to d235f87 Compare May 18, 2026 21:22
Comment thread src/sentry/api/endpoints/project_repo_link.py Outdated
POST /projects/{org}/{project}/repo-link/ creates a ProjectRepository
linking a project to an existing repository. Used by the SCM onboarding
flow to persist the user's repo selection.

Idempotent: returns 200 if the link already exists, 201 if created.
Scopes the repo lookup to the project's organization to prevent IDOR.

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
@wedamija wedamija force-pushed the danf/project-repo-link-endpoint branch from 38d37d3 to 4ea453c Compare May 18, 2026 21:43
@wedamija wedamija merged commit f33f66b into master May 19, 2026
64 of 65 checks passed
@wedamija wedamija deleted the danf/project-repo-link-endpoint branch May 19, 2026 16:44
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.

3 participants