Skip to content

Commit f8ba1f5

Browse files
committed
Handle paginated registry metadata responses (swiftlang#8219)
In [4.1 List Package Releases](https://github.com/swiftlang/swift-package-manager/blob/main/Documentation/PackageRegistry/Registry.md#41-list-package-releases) it is stated that a server may respond with a `Link` header that contains a pointer to a subsequent page of results. SwiftPM is not checking for the `next` link in the `Link` header and so if a registry returns paginated results, only the first page of versions is searched when resolving. This would result in a "version not found" error when in reality the version is present in a subsequent page of results. Respect the `next` link in the `Link` header by loading the next page of results and building up a list of versions, continuing until there is no `next` link present in the `Link` header of the last result. Registry servers that serve paginated results now have all their results read. Issue: swiftlang#8215
1 parent 890e42f commit f8ba1f5

File tree

3 files changed

+421
-105
lines changed

3 files changed

+421
-105
lines changed

Sources/PackageMetadata/PackageMetadata.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ public struct PackageSearchClient {
352352
) { result in
353353
do {
354354
let metadata = try result.get()
355-
let alternateLocations = metadata.alternateLocations ?? []
355+
let alternateLocations = metadata.alternateLocations
356356
return completion(.success(Set(alternateLocations)))
357357
} catch {
358358
return completion(.failure(error))

0 commit comments

Comments
 (0)