Repository navigation
Preserve the index media type when the index body omits it - #2235
Merged
TerryHowe merged 1 commit intoOct 14, 2026
Merged
Conversation
Co-Authored-By: Claude <[email protected]> Signed-off-by: Arpit Jain <[email protected]>
arpitjain099
requested review from
TerryHowe,
Wwwsylvia,
sabre1041,
sajayantony and
shizhMSFT
as code owners
October 14, 2026 11:15
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2235 +/- ##
==========================================
+ Coverage 56.23% 57.62% +1.39%
==========================================
Files 139 139
Lines 7453 6074 -1379
==========================================
- Hits 4191 3500 -691
+ Misses 3043 2355 -688
Partials 219 219 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it:
oras manifest index updatetakes the new descriptor's media type fromindex.MediaType, which is read out of the index body.mediaTypeis optional in older OCI indexes, so a body can omit it while the resolved descriptor correctly says image index.fetchIndexdoes gate the input withdescriptor.IsIndex(desc), but that checks the descriptor the registry or layout supplies, not the body. Withindex.MediaTypeempty,content.NewDescriptorFromBytessubstitutesapplication/octet-stream, the tag gets rewritten to point at it, and the artifact stops being resolvable as an index.I reproduced it on a hand-built OCI layout with no registry. The update reports success and exits 0, but the tag's descriptor goes from
application/vnd.oci.image.index.v1+jsontoapplication/octet-stream, and a secondindex updateon the same tag then fails withv1 is not an index.The fix falls back to
desc.MediaTypeinfetchIndex, which is already in scope and already validated. That also writesmediaTypeinto the new body, which OCI image-spec 1.1 requires for an index, so body and descriptor end up agreeing.create.gohardcodesocispec.MediaTypeImageIndex, and I deliberately did not copy that here: a Docker manifest list would be silently retyped, so this needs to be a fallback rather than a constant. The test covers that case.Test_fetchIndex_mediaTypehas three rows. The mediaType-less one fails on main withfetchIndex() MediaType = "", want "application/vnd.oci.image.index.v1+json"; the other two, a body that carries its mediaType and a Docker manifest list, pass either way.go test ./cmd/... ./internal/...is green.Which issue(s) this PR fixes:
None filed.
Please check the following list:
No E2E case exists for a mediaType-less index (
grep mediaType test/e2e/suite/command/manifest_index.gois empty). Happy to add one if you want it covered there as well.AI assistance was used on this change and is disclosed in the commit trailer.