Skip to content

Add RegistriesClient.GetPackage - #86

Merged
andrew merged 2 commits into
git-pkgs:mainfrom
simonchrz:registries-get-package
Oct 24, 2026
Merged

andrew merged 2 commits into
git-pkgs:mainfrom
simonchrz:registries-get-package

Conversation

@simonchrz

@simonchrz simonchrz commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

RegistriesClient.BulkLookup drops registry errors, so a caller that looks up one package can't report why it failed. The proxy needs the error for git-pkgs/proxy#562: /api/package answers 502 when the registry can't be queried.

GetPackage(ctx, purl) looks up one package and returns the registry's error. A missing package gives an error matching registries.ErrNotFound; an unreachable registry gives a different one.

LatestVersion follows the same policy as BulkLookup. When the registry doesn't advertise one, GetPackage selects it from FetchVersions with registries.SelectLatestVersion, using the registry it already built, so the package document is fetched once. If only that lookup fails the package is returned without LatestVersion, unless the context is done. GetPackage and BulkLookup build the PackageInfo with one helper, so they return the same fields.

GetPackage looks up one package and returns the registry error, which
BulkLookup drops. It fills LatestVersion with the same fallback as
BulkLookup, and both build the PackageInfo with one helper.
GetPackage now builds the registry once and selects the latest version
from FetchVersions, instead of FetchLatestVersionFromPURL fetching the
package a second time. A done context is returned rather than a package
without LatestVersion. The doc comment and test cover ErrNotFound for a
missing package.
@andrew
andrew merged commit 1e2684f into git-pkgs:main Oct 24, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants