Skip to content

pkg/name: only treat .localhost as non-HTTPS, not .local#2281

Merged
Subserial merged 3 commits into
google:mainfrom
blackwell-systems:fix/local-domain-https-scheme
Apr 29, 2026
Merged

pkg/name: only treat .localhost as non-HTTPS, not .local#2281
Subserial merged 3 commits into
google:mainfrom
blackwell-systems:fix/local-domain-https-scheme

Conversation

@blackwell-systems

Copy link
Copy Markdown
Contributor

The reLocal regex previously matched both .local and .localhost
domain suffixes, treating both as insecure (HTTP) registries. This
caused intermittent failures for users with FQDN registries ending in
.local, as the HTTP fallback path would trigger incorrect redirect
behavior.

Only .localhost domains should be treated as non-HTTPS by default,
per RFC 6761. Users with .local domains that genuinely need HTTP
can still pass the Insecure option explicitly.

Changes:

  • pkg/name/registry.go: regex changed from .*\.local(?:host)?(?::\d{1,5})?$ to .*\.localhost(?::\d{1,5})?$
  • pkg/name/registry_test.go: updated existing .local test to .localhost, added two new test cases verifying .local domains use HTTPS

Test results:

ok  github.com/google/go-containerregistry/pkg/name  0.544s

Fixes #2139

The reLocal regex previously matched both .local and .localhost
domain suffixes, treating both as insecure (HTTP) registries.
This caused intermittent failures for users with FQDN registries
ending in .local, as the HTTP fallback path would trigger
incorrect redirect behavior.

Only .localhost domains should be treated as non-HTTPS by default.
Users with .local domains that genuinely need HTTP can still pass
the Insecure option explicitly.

Fixes google#2139
@google-cla

google-cla Bot commented Apr 28, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

blackwell-systems and others added 2 commits April 28, 2026 15:41
TestPingHttpFallback used ko.local which no longer triggers the HTTP
fallback after the regex fix in pkg/name. Changed to ko.localhost to
match the updated behavior.
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.82%. Comparing base (64622f1) to head (95e876c).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2281   +/-   ##
=======================================
  Coverage   56.82%   56.82%           
=======================================
  Files         166      166           
  Lines       11279    11279           
=======================================
  Hits         6409     6409           
  Misses       4103     4103           
  Partials      767      767           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Subserial Subserial merged commit 2d86301 into google:main Apr 29, 2026
17 checks passed
Subserial pushed a commit to Subserial/go-containerregistry that referenced this pull request May 15, 2026
* pkg/name: only treat .localhost as non-HTTPS, not .local

The reLocal regex previously matched both .local and .localhost
domain suffixes, treating both as insecure (HTTP) registries.
This caused intermittent failures for users with FQDN registries
ending in .local, as the HTTP fallback path would trigger
incorrect redirect behavior.

Only .localhost domains should be treated as non-HTTPS by default.
Users with .local domains that genuinely need HTTP can still pass
the Insecure option explicitly.

Fixes google#2139

* pkg/v1/remote/transport: update ping test to use .localhost

TestPingHttpFallback used ko.local which no longer triggers the HTTP
fallback after the regex fix in pkg/name. Changed to ko.localhost to
match the updated behavior.
ab-ghosh added a commit to ab-ghosh/chains that referenced this pull request May 26, 2026
  go-containerregistry v0.21.6 changed .local domain handling to only
  treat .localhost as HTTP (google/go-containerregistry#2281). This
  breaks OCI storage for insecure registries using .cluster.local
  addresses since name.NewDigest() now defaults to HTTPS for them.

  Extract nameOpts() from newRepo() and reuse it in both NewDigest
  call sites so the insecure flag propagates consistently.

Signed-off-by: ab-ghosh <abghosh@redhat.com>
ab-ghosh added a commit to ab-ghosh/chains that referenced this pull request May 26, 2026
  go-containerregistry v0.21.6 changed .local domain handling to only
  treat .localhost as HTTP (google/go-containerregistry#2281). This
  breaks OCI storage for insecure registries using .cluster.local
  addresses since name.NewDigest() now defaults to HTTPS for them.

  Extract nameOpts() from newRepo() and reuse it in both NewDigest
  call sites so the insecure flag propagates consistently.

Signed-off-by: ab-ghosh <abghosh@redhat.com>
tekton-robot pushed a commit to tektoncd/chains that referenced this pull request Jun 8, 2026
go-containerregistry v0.21.6 changed .local domain handling to only
  treat .localhost as HTTP (google/go-containerregistry#2281). This
  breaks OCI storage for insecure registries using .cluster.local
  addresses since name.NewDigest() now defaults to HTTPS for them.

  Extract nameOpts() from newRepo() and reuse it in both NewDigest
  call sites so the insecure flag propagates consistently.

Signed-off-by: ab-ghosh <abghosh@redhat.com>
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.

ggcr: Intermittent failures due to heuristic non-HTTPS connections when accessing a registry FQDN ending in .local

3 participants