Repository navigation
feat(manifest): add omit_media_type to leave mediaType out of the manifest - #805
Merged
malt3 merged 1 commit intoOct 19, 2026
Merged
Conversation
…ifest image_manifest always writes a top-level mediaType. helm push does not, so a Helm chart built with rules_img cannot have the digest Helm gives the same chart. The new attribute, off by default, passes --omit-media-type to img manifest. The descriptor, index and layout entries and the registry Content-Type keep the image manifest type. deploy-metadata, the OCI layout writers, the distribution referrers listing, the deploy sink root and the BES syncer read the media type from the manifest bytes and failed or wrote an empty type without the field. They now use api.ImageManifestMediaType, which treats an empty value as the OCI image manifest type.
rdark
marked this pull request as ready for review
October 19, 2026 16:25
Merged
via the queue into
bazel-contrib:main
with commit Oct 19, 2026
2d567bb
24 of 26 checks passed
This was referenced Oct 20, 2026
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.
image_manifestalways writes a top-level"mediaType"into the manifest.helm pushdoes not, so a Helm chart built with rules_img cannot have the digest Helm gives the same chart. periareon/rules_helm#305 addshelm_deploy, which builds a chart as animage_manifestsomulti_deploycan push it. For itstests/helm_deploy:simplechart the config, layer and annotations matchhelm push, but the manifest issha256:ab07a521…andhelm push(3.16.3 and 4.2.0) givessha256:b6137ff1…. Removing the field is the only difference.This is a small, opt-in change in the shape of #742 (
omit_platform), so I went straight to a PR.Change
image_manifest(andimage_from_binary, which inherits its attributes) getsomit_media_type, defaultFalse, which passes the new--omit-media-typeflag toimg manifest. Existing manifests are byte-identical. Only the manifest bytes change: the descriptor, index and layout entries, and theContent-Typesent to a registry keepapplication/vnd.oci.image.manifest.v1+json. The OCI spec saysmediaTypeSHOULD be set, so the docstring says to keep the default unless a manifest must match one from another tool. Nothing rejects it on an ordinary image config; as withomit_platform, that is the caller's choice.Readers of the field
Several tool paths took the manifest's media type from its bytes. With the field absent they failed or wrote an empty
mediaType:img deploy-metadataput""in the root, manifest and referrer descriptors of the deploy request. A sink then wrote anindex.jsonentry with nomediaType(seen intests/omit_media_typewith the fix reverted), and the deploy VFS'sTaggable,LayersFromRootandDigestsFromRootreturn "unsupported media type" for an empty type.pkg/ocilayout(clean, annotated and root-descriptor index styles, and the editor) wrote empty entries for theoci_layout,oci_tarballand sparse layout outputs and theoci:sink. The distribution sink's referrers listing did the same.cmd/deploy's sink root took the type from the bytes for theoci-taranddocker-saveindex.json.img serve) sent an emptyContent-Typeon the manifest PUT, for a root manifest and for each child of an index.Each now uses
api.ImageManifestMediaType, which treats an empty value as the OCI image manifest type (Docker manifests must set the field). The syncer takes the type from the descriptor it fetched the manifest by. This also covers pulled OCI manifests that omit the field on these paths.Already safe without changes:
image_indexand signing (they read descriptors), containerd load and the lazy, dedup and eager push strategies (they read the deploy request), and the CAS registry,pkg/signerand the cached-blob transport (they already infer the type).Testing
oci-tar,oci,docker-saveanddistributionsinks, and a syncer push to an in-process registry that checks the PUTContent-Type. Each test fails with its fix reverted.tests/omit_media_typebuilds a Helm-config manifest and a SOCI-enabled image with the attribute and checks the built manifest, descriptor,oci_tarballoutput group and a push run with--sink oci-tar:. It is excluded on Windows, because no other test starts a pusher from a test there.bazel test //... @rules_img_tool//... @rules_img_internal_tools//...and//util:buildifier.checkpass on macOS (Bazel 9.1.1).omit_media_type = Trueinhelm_deploy:multi_deploypushedsimple,templateandplustocrane registry serveassha256:b6137ff1…,sha256:16fda365…andsha256:108e6fb7…, the same digests a realhelm push(3.16.3) gives for the same.tgzfiles. The registry returnsContent-Type: application/vnd.oci.image.manifest.v1+json, andhelm pullaccepts the chart.//e2e:integration_tests, and registries other thancrane registry serve.Not changed
image_indexalso hardcodes its top-levelmediaType.img optimizeadds the field back when it rewrites a manifest. Index roots withoutmediaTypestill give an empty descriptor in deploy metadata and sinks, which rules_img's own indexes never hit.syncocirefgraphrejects remote manifests without the field, as it already does for charts pushed byhelm push.