Skip to content

Commit

Permalink
Handle paginated registry metadata responses (swiftlang#8219)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
plemarquand committed Jan 30, 2025
1 parent 890e42f commit f8ba1f5
Show file tree
Hide file tree
Showing 3 changed files with 421 additions and 105 deletions.
2 changes: 1 addition & 1 deletion Sources/PackageMetadata/PackageMetadata.swift
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ public struct PackageSearchClient {
) { result in
do {
let metadata = try result.get()
let alternateLocations = metadata.alternateLocations ?? []
let alternateLocations = metadata.alternateLocations
return completion(.success(Set(alternateLocations)))
} catch {
return completion(.failure(error))
Expand Down
Loading

0 comments on commit f8ba1f5

Please sign in to comment.