Skip to content

client: add Accept headers to Exists() HEAD#4715

Merged
joaodrp merged 1 commit intodistribution:mainfrom
artem-tkachuk:fix-exists-accept-headers
Oct 16, 2025
Merged

client: add Accept headers to Exists() HEAD#4715
joaodrp merged 1 commit intodistribution:mainfrom
artem-tkachuk:fix-exists-accept-headers

Conversation

@artem-tkachuk
Copy link
Copy Markdown
Contributor

client: add Accept headers to Exists() HEAD

Adds Accept headers (from distribution.ManifestMediaTypes()) to the
HEAD request in (*manifests).Exists, aligning it with Get() and
fixing failures on registries that require explicit OCI media types.

Real-world example:

curl -sv -X HEAD \
  -H 'Accept: application/vnd.oci.image.manifest.v1+json' \
  'https://<registry>/v2/<repo>/manifests/sha256:<digest>'
# HTTP/1.1 200 OK
# Content-Type: application/vnd.oci.image.manifest.v1+json
# Docker-Content-Digest: sha256:<digest>

Without Accept, some registries return 404/406 even when the manifest
exists.

Tests:

  • Regression: Exists() true with Accept present; false when Accept is
    stripped (negative path).
  • Existing tests unchanged.

Risk/compatibility:

  • Low. Registries that ignore Accept on HEAD continue to work.
  • Redirect handling unchanged; CheckRedirect preserves Accept.

The manifest Exists() client call issued a HEAD without any Accept
headers. Some OCI-focused registries require an explicit Accept for
manifest content negotiation, causing HEAD to fail (404/406) even
when the manifest exists. The Get() path already sets Accept;
Exists() did not.

This change adds all supported manifest media types from
distribution.ManifestMediaTypes() as Accept headers to the Exists()
HEAD request, aligning behavior with Get() and improving OCI
interoperability.

Tests:
- Regression: Exists() returns true when Accept is present and
  false when stripped (negative path), mirroring real-world
  behavior.

Risk/compatibility:
- Low. Registries that ignore Accept on HEAD continue to work.
- Redirect handling is unchanged; existing CheckRedirect preserves
  Accept.

Signed-off-by: Artem Tkachuk <artemtkachuk@yahoo.com>
@artem-tkachuk
Copy link
Copy Markdown
Contributor Author

@milosgajdos Hello! Looks like I can't tag you as a reviewer. Would appreciate it if you could take a look at this when you get a chance. Thanks!

@milosgajdos milosgajdos requested a review from thaJeztah October 15, 2025 20:27
@joaodrp joaodrp merged commit 76fe617 into distribution:main Oct 16, 2025
21 checks passed
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.

3 participants