Skip to content

Artifactory: private GitHub repos require codeload.github.com workaround #710

@chkp-roniz

Description

@chkp-roniz

Summary

When using JFrog Artifactory as a remote repository proxy for GitHub, downloading archive (zip) files from private repositories (including GitHub EMU accounts) fails because GitHub uses a redirect-based download flow that Artifactory cannot follow with authentication.

Problem

GitHub serves archive downloads differently for private vs public repos:

  • Public repos: https://github.com/{owner}/{repo}/archive/refs/heads/{ref}.zip serves the zip directly — Artifactory can proxy this without issues.
  • Private repos: The same URL returns a 302 redirect to https://codeload.github.com/{owner}/{repo}/legacy.zip/refs/heads/{ref}?token=<temporary-token>. Artifactory's remote repository cannot follow this cross-host redirect with proper authentication, resulting in a 404.

Workaround

The workaround is to configure the Artifactory remote repository's upstream URL to point to https://codeload.github.com/ instead of https://github.com/. The codeload endpoint serves the zip directly with token authentication (no redirect), which Artifactory can proxy correctly.

However, the URL pattern changes:

  • github.com style: /{owner}/{repo}/archive/refs/heads/{ref}.zip
  • codeload.github.com style: /{owner}/{repo}/zip/refs/heads/{ref}

This means APM's build_artifactory_archive_url() in utils/github_host.py currently only generates github.com-style and gitlab-style archive URLs. It does not generate codeload.github.com-style URLs, so Artifactory remote repos configured with the codeload workaround won't match APM's expected URL patterns.

Impact

This affects any organization using:

  • GitHub EMU (Enterprise Managed Users) accounts with private repositories
  • JFrog Artifactory as a registry proxy for GitHub
  • APM for package management

Suggestion

Consider adding support for the codeload.github.com URL pattern in build_artifactory_archive_url():

# codeload.github.com style: /{owner}/{repo}/zip/refs/heads/{ref}
f"{base}/zip/refs/heads/{ref}",
# codeload.github.com tags fallback
f"{base}/zip/refs/tags/{ref}",

Additionally, APM could detect whether an Artifactory remote repo proxies github.com vs codeload.github.com and adjust the URL pattern accordingly.

Additional Artifactory Configuration Notes

For others hitting this issue, the Artifactory remote repository also requires:

  1. Token authentication enabled with a GitHub PAT that has repo access
  2. Include patterns set to allow the {owner}/{repo}/** path
  3. Upstream URL set to https://codeload.github.com/ for private repos

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedDirection approved, safe to start workenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions