Skip to content

feat(scm): Add 'get_repository'#112569

Closed
jacquev6 wants to merge 3 commits intomasterfrom
jacquev6/scm-platform/get-repository
Closed

feat(scm): Add 'get_repository'#112569
jacquev6 wants to merge 3 commits intomasterfrom
jacquev6/scm-platform/get-repository

Conversation

@jacquev6
Copy link
Copy Markdown
Collaborator

@jacquev6 jacquev6 commented Apr 9, 2026

This adds get_repository to the SCM platform, for GitHub and GitLab.

Client side PR is https://github.com/getsentry/seer/pull/5688.

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 9, 2026
Comment thread src/sentry/scm/private/providers/gitlab.py
Comment thread src/sentry/scm/private/providers/gitlab.py Outdated
@jacquev6 jacquev6 marked this pull request as ready for review April 9, 2026 10:09
@jacquev6 jacquev6 requested review from a team as code owners April 9, 2026 10:09
Copy link
Copy Markdown
Contributor

@cursor cursor bot left a 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.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit d2be5ea. Configure here.

Comment thread src/sentry/scm/actions.py

def get_repository(scm: GetRepositoryProtocol) -> ActionResult[GitRepository]:
"""Get the repository associated with this SourceCodeManager."""
return scm.get_repository()
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.

get_repository missing from module __all__ export list

Low Severity

The get_repository function, newly added to actions.py, isn't included in the module's __all__ tuple. This deviates from the established pattern for exporting action functions and may affect its availability for imports or registration.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit d2be5ea. Configure here.

repo_size = statistics.get("repository_size", 0) if statistics else 0
return GitRepository(
full_name=raw["path_with_namespace"],
default_branch=raw["default_branch"],
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is Warden right? should we update types to reflect this?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you referring to this #112569 (comment) ? If yes, I marked it as resolved because I think I fixed the issue in d2be5ea above.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah no, was referring to this annotation:

Image

default_branch can be null for empty GitLab repositories
Check warning: default_branch can be null for empty GitLab repositories
The map_repository function directly accesses raw["default_branch"] without handling the case where GitLab returns null for empty repositories (repositories with no commits or branches). According to GitLab API documentation, default_branch is null until the first commit creates a branch. The GitRepository TypedDict expects default_branch: str, so passing None violates the type contract and may cause downstream TypeError when the value is used as a string.

@jacquev6
Copy link
Copy Markdown
Collaborator Author

Replaced by getsentry/scm-platform#2.

@jacquev6 jacquev6 closed this Apr 14, 2026
cmanallen pushed a commit to getsentry/scm-platform that referenced this pull request Apr 14, 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants