fix(oci): extract index digest in verify step so attestation builds pass #56
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/verify-attestation-digest-LINKS-24"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
The Verify pushed image step in
build-oci-image.ymlfailed on everymainbuild with a spuriousDIGEST MISMATCH(LINKS-24, run #152). It compared the--iidfiledigest againstdocker buildx imagetools inspect $ref --format "{{.Manifest.Digest}}".The docker-container buildx driver attaches a provenance attestation by default, so the pushed ref is always an OCI image index: the
linux/amd64manifest plus anunknown/unknownattestation manifest. For an index,{{.Manifest.Digest}}does not reduce to the digest. buildx falls back to its full human-readable dump (Name: ... MediaType: ... Digest: ... Manifests: ...), so the captured$remoteis that whole block and never equals the pushed digest. The step exits 1 even though the publish succeeded.The publish itself is fine: the registry index digest equals the
--iidfilevalue. The buildcache499seen in the same run is non-fatal becausecache-tosetsignore-error=true. The broken verify was the only thing failing the job, so this is a code fix, not the infra/human action the triage guessed.Fix
Render the index descriptor as JSON and read
.digest:{{json .Manifest}}serializes the index descriptor (including thedigestfield), which nu parses natively and which equals the--iidfiledigest.Verification
Reproduced locally against a
registry:2with a docker-container buildx build (attestation index, image-agnostic verify logic):--iidfiledigest:sha256:e985...946eddc(the index){{.Manifest.Digest}}-> capturedName: localhost:5000/test:v0.4.0 ...(full dump) -> MISMATCH{{json .Manifest}} | from json | get digest->sha256:e985...946eddc-> Verified, exact matchConfirmed in nu 0.112.2 (the runner shell).
The Verify step rendered the pushed digest with `imagetools inspect --format "{{.Manifest.Digest}}"`. The docker-container buildx driver attaches a provenance attestation by default, so every pushed ref is an OCI image index (the linux/amd64 manifest plus an unknown/unknown attestation manifest). For an index, `{{.Manifest.Digest}}` does not reduce to the digest: buildx falls back to its full human-readable dump, so the captured value never equals the `--iidfile` digest and the job fails with a spurious DIGEST MISMATCH on every main build. The publish itself succeeds (the index digest matches `--iidfile`) and the buildcache 499 is non-fatal (`cache-to` sets `ignore-error=true`); the broken verify was the only thing exiting 1. Render the index descriptor as JSON and read `.digest`, which yields the bare index digest that matches the pushed value. Reproduced locally against a registry:2 with a docker-container build: old logic captured `Name: ...` and mismatched, new logic verified the index digest sha256 exactly. #LINKS-24 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>