Skip to content

feat(scm): Add get_archive_link to SCM API#110987

Draft
billyvg wants to merge 5 commits intomasterfrom
billyvong/cw-1049-add-get_archive_link-action-to-scm
Draft

feat(scm): Add get_archive_link to SCM API#110987
billyvg wants to merge 5 commits intomasterfrom
billyvong/cw-1049-add-get_archive_link-action-to-scm

Conversation

@billyvg
Copy link
Member

@billyvg billyvg commented Mar 18, 2026

This adds a new API to get a download repository URL. Note that GitHub returns 302 with a presigned URL in the Location header whereas GitLab streams the content directly. I believe we also need to supply an auth header for GitLab as well (but havent confirmed yet).

This is needed to replicate behavior for downloading a repo in Seer

@linear-code
Copy link

linear-code bot commented Mar 18, 2026

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Mar 18, 2026
@billyvg billyvg requested a review from cmanallen March 18, 2026 17:41
@github-actions
Copy link
Contributor

github-actions bot commented Mar 18, 2026

Backend Test Failures

Failures on 46e88ad in this run:

tests/sentry/scm/unit/test_gitlab_provider.py::TestGetArchiveLink::test_empty_ref_omits_sha_paramlog
tests/sentry/scm/unit/test_gitlab_provider.py:13104: in test_empty_ref_omits_sha_param
    client.get_access_token.return_value = {
/opt/hostedtoolcache/Python/3.13.1/x64/lib/python3.13/unittest/mock.py:688: in __getattr__
    raise AttributeError("Mock object has no attribute %r" % name)
E   AttributeError: Mock object has no attribute 'get_access_token'
tests/sentry/scm/unit/test_gitlab_provider.py::TestGetArchiveLink::test_returns_tar_gz_urllog
tests/sentry/scm/unit/test_gitlab_provider.py:13074: in test_returns_tar_gz_url
    client.get_access_token.return_value = {
/opt/hostedtoolcache/Python/3.13.1/x64/lib/python3.13/unittest/mock.py:688: in __getattr__
    raise AttributeError("Mock object has no attribute %r" % name)
E   AttributeError: Mock object has no attribute 'get_access_token'
tests/sentry/scm/unit/test_gitlab_provider.py::TestGetArchiveLink::test_returns_zip_urllog
tests/sentry/scm/unit/test_gitlab_provider.py:13089: in test_returns_zip_url
    client.get_access_token.return_value = {
/opt/hostedtoolcache/Python/3.13.1/x64/lib/python3.13/unittest/mock.py:688: in __getattr__
    raise AttributeError("Mock object has no attribute %r" % name)
E   AttributeError: Mock object has no attribute 'get_access_token'

billyvg added 4 commits March 18, 2026 17:54
This adds a new API to get a download repository URL. Note that GitHub returns 302 with a presigned URL in the Location header whereas GitLab streams the content directly. I believe we also need to supply an auth header for GitLab as well (but havent confirmed yet)
@billyvg billyvg force-pushed the billyvong/cw-1049-add-get_archive_link-action-to-scm branch from edea82f to fcfc913 Compare March 18, 2026 21:56
@github-actions
Copy link
Contributor

github-actions bot commented Mar 18, 2026

Backend Test Failures

Failures on f49cd51 in this run:

tests/sentry/scm/unit/test_github_provider.py::TestGetArchiveLink::test_returns_archive_urllog
tests/sentry/scm/unit/test_github_provider.py:1355: in test_returns_archive_url
    result = provider.get_archive_link("main")
src/sentry/scm/private/providers/github.py:135: in wrapper
    return fn(*args, **kwargs)
src/sentry/scm/private/providers/github.py:718: in get_archive_link
    github_format = GITHUB_ARCHIVE_FORMAT_MAP[archive_format]
E   KeyError: 'tar.gz'
tests/sentry/scm/unit/test_github_provider.py::test_raises_scm_provider_exception_on_api_error[get_archive_link-kwargs47]log
tests/sentry/scm/unit/test_github_provider.py:140: in test_raises_scm_provider_exception_on_api_error
    getattr(provider, method)(**kwargs)
src/sentry/scm/private/providers/github.py:135: in wrapper
    return fn(*args, **kwargs)
src/sentry/scm/private/providers/github.py:718: in get_archive_link
    github_format = GITHUB_ARCHIVE_FORMAT_MAP[archive_format]
E   KeyError: 'tar.gz'

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.

1 participant