Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set mediaType from http response if manifest mediaType is not present #44530

Merged
merged 3 commits into from
Nov 5, 2024

Conversation

surayya-MS
Copy link
Member

@surayya-MS surayya-MS commented Oct 30, 2024

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.

skopeo copy docker://mcr.microsoft.com/dotnet/aspnet:8.0 oci:/path/to/aspnet_oci:latest
skopeo oci:/path/to/aspnet_oci:latest docker://docker.io/{user}/my-aspnet:8.0

that image manifest didn't have mediaType. I got "error MSB4018: The "CreateNewImage" task failed unexpectedly." that failed here :

var manifest = (await initialManifestResponse.Content.ReadFromJsonAsync<ManifestV2>(cancellationToken: cancellationToken).ConfigureAwait(false))!;

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.

@surayya-MS surayya-MS requested a review from baronfel October 30, 2024 14:29
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Containers Related to dotnet SDK containers functionality untriaged Request triage from a team member labels Oct 30, 2024
@surayya-MS surayya-MS self-assigned this Oct 30, 2024
@surayya-MS surayya-MS requested a review from a team as a code owner October 31, 2024 10:03
@surayya-MS surayya-MS changed the title Don't force base image manifests to have a mediaType Set mediaType from http response if manifest mediaType is missing Oct 31, 2024
@surayya-MS surayya-MS changed the title Set mediaType from http response if manifest mediaType is missing Set mediaType from http response if manifest mediaType is not present Oct 31, 2024
@surayya-MS surayya-MS added DO NOT MERGE and removed untriaged Request triage from a team member labels Oct 31, 2024
@baronfel
Copy link
Member

baronfel commented Nov 4, 2024

Approved over email.

@baronfel baronfel modified the milestone: 8.0.11 Nov 4, 2024
@baronfel
Copy link
Member

baronfel commented Nov 5, 2024

Merging as the branch versions are bumped!

@baronfel baronfel merged commit 00555da into dotnet:release/8.0.4xx Nov 5, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Containers Related to dotnet SDK containers functionality Servicing-approved
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants