Skip to content

ref(integrations): Generalize repo sync task to all SCM providers#112545

Merged
wedamija merged 4 commits intomasterfrom
danf/sync-repos-fix-installation-id
Apr 10, 2026
Merged

ref(integrations): Generalize repo sync task to all SCM providers#112545
wedamija merged 4 commits intomasterfrom
danf/sync-repos-fix-installation-id

Conversation

@wedamija
Copy link
Copy Markdown
Member

@wedamija wedamija commented Apr 8, 2026

Required to get #112519 working for all scms.

Expand the periodic repo sync from GitHub-only to provider-agnostic. The task now uses each provider's get_repositories() and external_id instead of GitHub-specific API calls, with per-provider feature flags to control rollout.

Currently enabled for GitHub, GitHub Enterprise, and VSTS. GitLab and Bitbucket are blocked on a pre-existing issue where create_repositories eagerly creates webhooks for all repos before checking if they already exist. Perforce lacks external_id support.

@wedamija wedamija requested a review from a team April 8, 2026 22:07
@wedamija wedamija requested review from a team as code owners April 8, 2026 22:07
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 8, 2026
@wedamija wedamija force-pushed the danf/sync-repos-task-generalize branch from 95097c5 to 6749a24 Compare April 9, 2026 17:55
@wedamija wedamija requested a review from a team as a code owner April 9, 2026 17:55
Base automatically changed from danf/sync-repos-task-generalize to master April 9, 2026 18:12
@wedamija wedamija force-pushed the danf/sync-repos-fix-installation-id branch from 56be708 to d41bcd7 Compare April 9, 2026 18:23
@wedamija wedamija changed the title chore(integrations): Fix repo sync to pass installation id consistently ref(integrations): Generalize repo sync task to all SCM providers Apr 10, 2026
wedamija added 2 commits April 9, 2026 17:10
Required to get #112519 working for all scms. integration_id and installation are the same, but different scms use them. I don't want to refactor how the scms work, so just providing both.
Expand the periodic repo sync from GitHub-only to provider-agnostic. The task now uses each provider's get_repositories() and external_id instead of GitHub-specific API calls, with per-provider feature flags to control rollout.

Currently enabled for GitHub, GitHub Enterprise, and VSTS. GitLab and Bitbucket are blocked on a pre-existing issue where create_repositories eagerly creates webhooks for all repos before checking if they already exist. Perforce lacks external_id support.
Comment thread src/sentry/integrations/source_code_management/sync_repos.py
Comment thread src/sentry/integrations/source_code_management/sync_repos.py
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 10, 2026

Backend Test Failures

Failures on 3f98ac0 in this run:

tests/sentry/integrations/gitlab/test_issues.py::GitlabIssuesTest::test_create_issue_default_project_not_in_api_calllog
[gw1] linux -- Python 3.13.1 /home/runner/work/sentry/sentry/.venv/bin/python3
tests/sentry/integrations/gitlab/test_issues.py:315: in test_create_issue_default_project_not_in_api_call
    assert self.installation.get_create_issue_config(self.group, self.user) == [
src/sentry/silo/base.py:157: in override
    return original_method(*args, **kwargs)
src/sentry/integrations/gitlab/issues.py:72: in get_create_issue_config
    default_project, project_choices = self.get_projects_and_default(group, params, **kwargs)
src/sentry/integrations/gitlab/issues.py:53: in get_projects_and_default
    default_project, project_choices = self.get_repository_choices(group, params_mut)
src/sentry/integrations/source_code_management/issues.py:79: in get_repository_choices
    return self._get_repository_choices(
src/sentry/integrations/source_code_management/issues.py:40: in _get_repository_choices
    repos = self.get_repositories(page_number_limit=page_number_limit)
src/sentry/integrations/gitlab/integration.py:193: in get_repositories
    "url": repo["web_url"],
E   KeyError: 'web_url'
tests/sentry/integrations/gitlab/test_issues.py::GitlabIssuesTest::test_get_create_issue_configlog
[gw1] linux -- Python 3.13.1 /home/runner/work/sentry/sentry/.venv/bin/python3
tests/sentry/integrations/gitlab/test_issues.py:67: in test_get_create_issue_config
    assert self.installation.get_create_issue_config(self.group, self.user) == [
src/sentry/silo/base.py:157: in override
    return original_method(*args, **kwargs)
src/sentry/integrations/gitlab/issues.py:72: in get_create_issue_config
    default_project, project_choices = self.get_projects_and_default(group, params, **kwargs)
src/sentry/integrations/gitlab/issues.py:53: in get_projects_and_default
    default_project, project_choices = self.get_repository_choices(group, params_mut)
src/sentry/integrations/source_code_management/issues.py:79: in get_repository_choices
    return self._get_repository_choices(
src/sentry/integrations/source_code_management/issues.py:40: in _get_repository_choices
    repos = self.get_repositories(page_number_limit=page_number_limit)
src/sentry/integrations/gitlab/integration.py:193: in get_repositories
    "url": repo["web_url"],
E   KeyError: 'web_url'
tests/sentry/integrations/gitlab/test_issues.py::GitlabIssuesTest::test_create_issue_default_project_in_group_api_calllog
[gw0] linux -- Python 3.13.1 /home/runner/work/sentry/sentry/.venv/bin/python3
tests/sentry/integrations/gitlab/test_issues.py:247: in test_create_issue_default_project_in_group_api_call
    assert self.installation.get_create_issue_config(self.group, self.user) == [
src/sentry/silo/base.py:157: in override
    return original_method(*args, **kwargs)
src/sentry/integrations/gitlab/issues.py:72: in get_create_issue_config
    default_project, project_choices = self.get_projects_and_default(group, params, **kwargs)
src/sentry/integrations/gitlab/issues.py:53: in get_projects_and_default
    default_project, project_choices = self.get_repository_choices(group, params_mut)
src/sentry/integrations/source_code_management/issues.py:79: in get_repository_choices
    return self._get_repository_choices(
src/sentry/integrations/source_code_management/issues.py:40: in _get_repository_choices
    repos = self.get_repositories(page_number_limit=page_number_limit)
src/sentry/integrations/gitlab/integration.py:193: in get_repositories
    "url": repo["web_url"],
E   KeyError: 'web_url'
tests/sentry/integrations/gitlab/test_issues.py::GitlabIssuesTest::test_get_link_issue_configlog
[gw0] linux -- Python 3.13.1 /home/runner/work/sentry/sentry/.venv/bin/python3
tests/sentry/integrations/gitlab/test_issues.py:106: in test_get_link_issue_config
    assert self.installation.get_link_issue_config(self.group) == [
src/sentry/integrations/gitlab/issues.py:144: in get_link_issue_config
    default_project, project_choices = self.get_projects_and_default(group, params, **kwargs)
src/sentry/integrations/gitlab/issues.py:53: in get_projects_and_default
    default_project, project_choices = self.get_repository_choices(group, params_mut)
src/sentry/integrations/source_code_management/issues.py:79: in get_repository_choices
    return self._get_repository_choices(
src/sentry/integrations/source_code_management/issues.py:40: in _get_repository_choices
    repos = self.get_repositories(page_number_limit=page_number_limit)
src/sentry/integrations/gitlab/integration.py:193: in get_repositories
    "url": repo["web_url"],
E   KeyError: 'web_url'

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 1b9e607. Configure here.

Comment thread src/sentry/integrations/source_code_management/sync_repos.py
@wedamija wedamija merged commit 8eb4dae into master Apr 10, 2026
77 checks passed
@wedamija wedamija deleted the danf/sync-repos-fix-installation-id branch April 10, 2026 17:46
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.

3 participants