Set mediaType from http response if manifest mediaType is not present #44530
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.
Context
Fixes dotnet/sdk-container-builds#567.
Customer impact
Some (rare) images do not have a media type, which instructs container tooling how to interpret the data in the container image. Our tooling incorrectly interpreted the spec and required the mediaType to be present, instead of probing and defaulting to a fallback mediaType if one is present. Without this change, users using custom base images may be blocked from using the SDK tooling.
Details
Manifest MediaType field is optional in the docs.
I found this when I was trying to set base image as an oci image. For that i used
skopeo
to convert aspnet 8 to oci image.that image manifest didn't have mediaType. I got "error MSB4018: The "CreateNewImage" task failed unexpectedly." that failed here :
sdk/src/Containers/Microsoft.NET.Build.Containers/Registry/Registry.cs
Line 213 in 1ed097e
Changes
Made ManifestV2.MediaType optional
Set mediaType from http response content for image building in case when manifest mediaType is not present.
Related #40776
Risk
Low - These images are rare in the wild, though some fairly-widely-used tooling does seem to trigger this corner case.