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

ContainerRegistry: Tolerate missing Location header in the manifest PUT response #27

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions Sources/ContainerRegistry/Manifests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@ public extension RegistryClient {
decodingErrors: [.notFound]
)

guard let location = httpResponse.response.headerFields[.location] else {
throw HTTPClientError.missingResponseHeader("Location")
}
return location
// The distribution spec says the response MUST contain a Location header
// providing a URL from which the saved manifest can be downloaded.
// However some registries return URLs which cannot be fetched, and
// ECR does not set this header at all.
// If the header is not present, create a suitable value.
// https://github.com/opencontainers/distribution-spec/blob/main/spec.md#pulling-manifests
return try httpResponse.response.headerFields[.location]
?? registryURLForPath("/v2/\(repository)/manifests/\(manifest.digest)").absoluteString
}

func getManifest(repository: String, reference: String) async throws -> ImageManifest {
Expand Down