fix: order versions by createTime desc so latest is reachable on >1000-version packages#6
Open
vladimirtomecko wants to merge 1 commit into
Open
Conversation
…0-version packages GAR's versions.list endpoint defaults to ASC ordering by createTime and caps server-side pageSize at 1000 regardless of requested value. For any package with more than 1000 versions, the existing single-page fetch returns the oldest 1000 — the newest releases are unreachable, so the synthesized maven-metadata.xml advertises stale `<latest>` / `<release>` values and Coursier/sbt consumers (and downstream tools like Scala Steward) never see new versions. Adding `orderBy=createTime desc` flips the first page to newest-first, so the most recent 1000 versions are visible — sufficient for the "resolve latest version" use case that Maven metadata is built for. The `desc` suffix follows the standard Google list-ordering syntax defined in AIP-132. `createTime` is a documented sortable field on the GAR Version resource. Docs: - versions.list reference (states "Maximum page size is 1,000"): https://cloud.google.com/artifact-registry/docs/reference/rest/v1/projects.locations.repositories.packages.versions/list - AIP-132 (List), section on order_by syntax with `desc` suffix: https://google.aip.dev/132 Verified empirically against a live GAR repo: with the parameter, versions.list returns 1.863.6, 1.863.5, 1.863.4, ... (newest first); without it, the same call returns 0.0.100, 0.0.101, ... (oldest first).
|
@rolang, could you please take a look? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
GAR's versions.list endpoint:
createTime(oldest first).pageSizeat 1,000 regardless of requested value (documented at the link above: "Maximum page size is 1,000.").The existing single-page fetch in
ArtifactRegistryUrlConnectionalways returns the oldest 1,000 versions for any package that has more than 1,000 versions. The newest releases are unreachable, so the synthesizedmaven-metadata.xmlends up with stale<latest>/<release>values and downstream consumers (Coursier, sbt, Scala Steward, etc.) silently never see new versions.Real-world example from our org: a Maven artifact had 1,343 published versions in GAR; the latest in
maven-metadata.xmlcame back as a version that was several months old, while the actual newest version (released hours earlier) was invisible. Scala Steward did not propose any bump and silently skipped the dependency on every run.Fix
Add
orderBy=createTime descto theversions.listrequest. The first (and, in practice, only) page now contains the newest 1,000 versions, which is what Maven-metadata consumers need to resolve the latest version.newUrl.put("fields", "versions.name,versions.createTime") newUrl.put("pageSize", 1000) + // Default ASC ordering hides the latest versions on packages with >1000 versions (server-side pageSize cap is 1000). + newUrl.put("orderBy", "createTime desc")Why this syntax should be correct
orderByis documented as a query param on versions.list (Optional. The field to order the results by.).<field> descsuffix is the standard Google list-ordering syntax defined in AIP-132:createTimeis a documented field on the Version resource.Verification
Probed live against a GAR repo (
pageSize=10):Without
orderBy:With
orderBy=createTime desc:Tried
pageSize=2000,5000,10000— server returns at most 1,000 items in every case (matches docs), so the only correct fix for the "hide latest" symptom is to flip the ordering.Scope / non-goals
This is the minimal change that unblocks consumers for the "resolve latest version" use case, which covers all Maven-metadata usage of the URL handler.
Resolving a specific old version that is older than the newest 1,000 still requires the consumer to know the exact version (Coursier already passes the version directly in the artifact URL — only metadata listings hit
versions.list). Full pagination vianextPageTokencould be added later as an additive change; this PR is deliberately limited to the one-line fix that resolves the latest-version bug.