Skip to content

build: omit empty :tag / @digest segments when rebuilding oci-layout ref#3809

Closed
SAY-5 wants to merge 1 commit intodocker:masterfrom
SAY-5:fix/oci-layout-digest-only-3793
Closed

build: omit empty :tag / @digest segments when rebuilding oci-layout ref#3809
SAY-5 wants to merge 1 commit intodocker:masterfrom
SAY-5:fix/oci-layout-digest-only-3793

Conversation

@SAY-5
Copy link
Copy Markdown

@SAY-5 SAY-5 commented Apr 22, 2026

Summary

Fixes #3793.

resolveBuildContext concatenated the parsed oci-layout ref back into a FrontendAttr via:

target.FrontendAttrs["context:"+k] = "oci-layout://" + storeName + ":" + tag + "@" + dig

When the user passed a digest-only context (oci-layout:///path@sha256:...), ocilayout.Parse returned tag == "", so the concat produced oci-layout://<storeID>:@sha256:.... The downstream frontend's reference parser rejects the empty : segment with invalid reference format. The regression arrived in v0.33.0 alongside the oci-layout parse refactor.

Fix

Build the attr piecewise: only append ":" + tag when tag is non-empty and "@" + dig when digest is non-empty. Tag-only (:1.3) and tag+digest refs retain their existing serialization.

Test plan

  • go build ./build/... clean
  • go vet ./build/... clean
  • go test ./build/... ./util/ocilayout/... green (existing TestParse already covers the digest-only Parse case; this fix lives in the re-serialization step, which has no unit-level harness — the frontend contract is what enforces it, and the issue reporter's repro now goes through).
  • Manual: docker buildx build --build-context proxy=oci-layout:///some/layout@sha256:<digest> . no longer errors with invalid reference format.

resolveBuildContext concatenated the parsed oci-layout ref back into
a FrontendAttr via 'oci-layout://' + storeName + ':' + tag + '@' + dig
unconditionally. When the user passed a digest-only context
(oci-layout:///path@sha256:...), the Parse result left tag empty, so
the concat produced 'oci-layout://<storeID>:@sha256:...' which fails
the frontend's reference parser with 'invalid reference format'. This
regressed in v0.33.0 along with the oci-layout parsing refactor
(docker#3793).

Build the attr piecewise, only appending ':tag' when tag is non-empty
and '@digest' when digest is non-empty. Tag-only and tag+digest refs
are unchanged.

Fixes docker#3793

Signed-off-by: SAY-5 <SAY-5@users.noreply.github.com>
@crazy-max
Copy link
Copy Markdown
Member

Thanks for working on this and for taking the time to put together. We ended up moving forward with a repo-native follow-up in #3811 and #3812 so we can land the change in the shape we want, with the test coverage and integration coverage aligned with the rest of the codebase.

Because of that, I'm going to close this PR so the work stays consolidated in one place. We appreciate the report and the attempted fix.

@crazy-max crazy-max closed this Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Regression on digest-only oci-layout:// build contexts

2 participants