Skip to content

download: restore artifact-domain fallback for GHCR bottles#22011

Open
coder999999999 wants to merge 3 commits intoHomebrew:mainfrom
coder999999999:codex/homebrew-21892-artifact-domain-fallback
Open

download: restore artifact-domain fallback for GHCR bottles#22011
coder999999999 wants to merge 3 commits intoHomebrew:mainfrom
coder999999999:codex/homebrew-21892-artifact-domain-fallback

Conversation

@coder999999999
Copy link
Copy Markdown

@coder999999999 coder999999999 commented Apr 14, 2026

Fixes #21892


  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests (excluding integration tests) for your changes? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) with your changes locally?

  • AI was used to generate or assist with generating this PR. Please specify below how you used AI to help you, and what steps you have taken to manually verify the changes.

This fixes HOMEBREW_ARTIFACT_DOMAIN fallback for GHCR bottle downloads. When an artifact mirror URL fails, Homebrew can now retry the original ghcr.io URL unless HOMEBREW_ARTIFACT_DOMAIN_NO_FALLBACK is set. The change also preserves existing authorization headers on artifact-mirror requests while still restoring GitHub Packages auth for real ghcr.io fallback requests.

I used Codex (GPT-5) to help draft and iterate on the patch and PR text. I manually reviewed the resulting changes, reproduced the original failure locally on macOS, verified both fallback and no-fallback brew fetch --force-bottle xz behaviour, ran targeted download-strategy tests and style checks, and ran bin/brew lgtm successfully on this branch.

Copilot AI review requested due to automatic review settings April 14, 2026 02:19
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes HOMEBREW_ARTIFACT_DOMAIN behavior for GHCR bottle downloads by ensuring Homebrew can retry the original ghcr.io URL when an artifact mirror fails, and by restoring GitHub Packages auth headers for real ghcr.io fallback requests.

Changes:

  • Precompute candidate download URLs so artifact-mirror failures can fall back to the original ghcr.io URL unless HOMEBREW_ARTIFACT_DOMAIN_NO_FALLBACK is set.
  • Restore GitHub Packages auth headers for ghcr.io requests (while not adding them for artifact-mirror requests).
  • Add regression tests covering fallback behavior and HOMEBREW_ARTIFACT_DOMAIN_NO_FALLBACK.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
Library/Homebrew/download_strategy.rb Builds URL candidates up front for artifact-domain fallback; adds conditional GitHub Packages auth injection for ghcr.io requests.
Library/Homebrew/test/download_strategies/curl_spec.rb Adds regression coverage for artifact-domain fallback vs. no-fallback behavior.
Library/Homebrew/test/download_strategies/curl_github_packages_spec.rb Adds coverage ensuring auth is restored for ghcr.io requests but not added for artifact-mirror URLs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Library/Homebrew/download_strategy.rb Outdated
@MikeMcQuaid
Copy link
Copy Markdown
Member

Will reopen when you're using the PR template.

Copy link
Copy Markdown
Author

Updated the PR body to use the repository template, added the required AI disclosure, and ran bin/brew lgtm successfully on this branch. If this now matches what you wanted, would you mind reopening the PR?

@MikeMcQuaid MikeMcQuaid reopened this Apr 14, 2026
Copy link
Copy Markdown
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! A few comments.

Comment thread Library/Homebrew/download_strategy.rb Outdated
Comment thread Library/Homebrew/download_strategy.rb Outdated
Comment thread Library/Homebrew/test/download_strategies/curl_github_packages_spec.rb Outdated
Comment thread Library/Homebrew/download_strategy.rb Outdated
Comment thread Library/Homebrew/download_strategy.rb Outdated
Comment thread Library/Homebrew/download_strategy.rb Outdated
Copy link
Copy Markdown
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Thanks!

CI is failing: https://github.com/Homebrew/brew/actions/runs/24467014618/job/71496786078?pr=22011

please ensure you are running brew lgtm before pushing.

end

sig { params(url: String, _block: T.proc.returns(T.untyped)).returns(T.untyped) }
def with_github_packages_auth(url, &_block)
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.

I'm not sure I understand why this is required now and wasn't before? Can you explain?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HOMEBREW_ARTIFACT_DOMAIN does not fallback to ghcr.io URLs

3 participants