Skip to content

Resolve a gem's platform build through its artifacts - #147

Merged
andrew merged 1 commit into
git-pkgs:mainfrom
charlie-morrison:gem-platform-artifacts
Nov 15, 2026
Merged

andrew merged 1 commit into
git-pkgs:mainfrom
charlie-morrison:gem-platform-artifacts

Conversation

@charlie-morrison

@charlie-morrison charlie-morrison commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #142

pkg:gem/jruby-launcher@1.1.2?platform=java now resolves to jruby-launcher-1.1.2-java.gem.

The RubyGems adapter lists one version per number, with each platform build as an artifact that carries platform in its metadata, the way vscode-extension lists builds. The version's own fields (integrity, platform, downloads) come from the ruby build when there is one, and from the first build listed otherwise. qualifiersMatch treats a ruby build like a universal one: it serves any platform, after a build for the platform asked for.

Gems with both kinds of build had the same gap. pkg:gem/nokogiri@1.13.6?platform=x86_64-linux resolved to the ruby gem nokogiri-1.13.6.gem, because the listed 1.13.6 had no artifacts and the resolver fell back to the built URL. It now gets nokogiri-1.13.6-x86_64-linux.gem.

Two behaviour changes worth a look:

  • FetchVersions no longer returns 1.13.6-x86_64-linux as a version of its own. Platform builds are in Artifacts now, and TestFetchVersions is updated for that.
  • With a platform qualifier, the gem URL goes through checkMetadataURL like any listed artifact, so it needs https and has to pass the resolver's address policy. A plain http:// gem mirror asked for a platform build now gets ErrUnsafeURL where it used to get the built URL.

Tests: TestResolveRubyGemsPlatform covers a platform-only version, both builds with each platform, a ruby-only version, and a platform with no build. On main 3 of its 6 cases fail: the java-only gem, nokogiri on x86_64-linux, and the no-build case, which returned a URL instead of ErrNoMatchingArtifact. Against rubygems.org, jruby-launcher 1.1.2 (java), nokogiri 1.16.0 (x86_64-linux and ruby) and rake 13.2.1 (x86_64-linux) all resolve to the right file with its sha256. go test ./..., go vet and golangci-lint are clean.

Summary by CodeRabbit

  • New Features
    • RubyGems releases now group platform-specific builds under the same version, with each build available as a separate artifact.
    • When selecting an artifact, exact platform matches are preferred. A ruby build can be selected as a fallback when no exact match is available.
  • Bug Fixes
    • Version listings now distinguish releases by version number rather than treating platform suffixes as separate versions.

RubyGems lists each platform build of a version as its own entry, and the
adapter numbered them <number>-<platform>, so a PURL with a platform
qualifier never matched a listed version and fell back to the ruby
download URL. The adapter now lists one version per number with each
build as an artifact carrying its platform, as Open VSX builds are
listed, and the resolver treats a ruby build like a universal one.

Fixes git-pkgs#142

Co-authored-by: Claude <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The RubyGems adapter groups platform builds under unsuffixed version numbers and records each build as an artifact. The resolver can select an exact platform artifact or use a ruby artifact as a fallback.

Changes: RubyGems platform handling

Layer / File(s) Summary
Group builds into version artifacts
internal/rubygems/rubygems.go, internal/rubygems/rubygems_test.go
FetchVersions groups builds by version and records each build’s filename, URL, integrity, and platform metadata. Tests check the grouped versions and artifacts.
Select platform artifacts
fetch/resolver.go, fetch/rubygems_resolver_test.go
When universal platforms are allowed, the resolver accepts ruby artifacts as fallbacks. Tests cover exact-platform selection, ruby fallback, and cases with no matching artifact.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: andrew, simonchrz

Merge Risk: Minimal · up to 1c4ef

RubyGems platform-qualified requests now resolve to the matching platform gem file, with a ruby build as a fallback. No merge-blocking issue was identified.

Security architecture risk: Minimal · up to 1c4ef

Platform builds now retain their own filenames and checksums under a shared version. The inspected selection path preserves exact-platform preference and applies existing URL restrictions before returning a listed artifact. No introduced or worsened security or failure-containment risk was established.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The changed authority is artifact selection within the calling process: caller-supplied qualifiers filter registry-provided build metadata into a returned URL, filename, and checksum. The inspected changes do not add credential access, execution authority, or persistent state ownership.

Trust Boundaries and Controls

  • observed — Listed artifacts cross the existing URL gate after candidate matching and before return. It requires HTTPS and a hostname and checks resolved addresses against the configured policy. DNS lookup failure is left to download-time failure; selection-time validation is not a substitute for download-time network enforcement.
  • observed — Unqualified built-URL resolution and the ErrNotFound or ErrNoDownloadURL fallback still bypass the metadata URL gate, as before this PR. RubyGems constructs these URLs from its configured base plus name and version, not from a response-provided download URL. The new artifact path therefore tightens validation for matched platform builds without removing the pre-existing configured-origin paths.

Resilience and Maintainability Implications

  • observed — An unsafe selected artifact fails immediately, and exhaustion of matching listed artifacts returns ErrNoMatchingArtifact. Neither result triggers the configured-URL recovery branch, preserving failure containment for the newly populated artifact lists.
Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "Resolve a gem's platform build through its artifacts" matches the main change. The PR lists platform builds as artifacts with platform metadata, so resolution uses them. The resolver now ac…
Linked Issues check Passed Issue #142 requires a RubyGems PURL with a non-ruby platform qualifier to resolve to {name}-{version}-{platform}.gem. The PR takes the artifact approach the issue describes as the first option. …
Out of Scope Changes check Passed The changes follow from the artifact approach in #142. FetchVersions stops returning platform builds as separate versions. The TestFetchVersions update matches that change. The resolver's ruby f…
Full details: Title check

Explanation

The title "Resolve a gem's platform build through its artifacts" matches the main change. The PR lists platform builds as artifacts with platform metadata, so resolution uses them. The resolver now accepts ruby builds as fallbacks, and FetchVersions groups builds by version number. The title names the primary change and is specific to the RubyGems adapter.

Full details: Linked Issues check

Explanation

Issue #142 requires a RubyGems PURL with a non-ruby platform qualifier to resolve to {name}-{version}-{platform}.gem. The PR takes the artifact approach the issue describes as the first option. internal/rubygems/rubygems.go now groups platform builds under one version number and records each build as a .gem artifact with its platform-specific filename, download URL, integrity, and platform metadata. fetch/resolver.go treats ruby like universal as a fallback after an exact platform build. TestResolveRubyGemsPlatform covers the java-only gem (#142 example), mixed builds on nokogiri 1.13.6 for x86_64-linux, ruby-only, and no-matching-build cases, and checks the resolved filename and URL. The reviewed summary supports this behaviour. The PR author also reports live rubygems.org checks, which I did not run. Runtime results rest on the author report and the unit tests. No non-coding requirement is in scope.

Full details: Out of Scope Changes check

Explanation

The changes follow from the artifact approach in #142. FetchVersions stops returning platform builds as separate versions. The TestFetchVersions update matches that change. The resolver's ruby fallback handling and the TestResolveRubyGemsPlatform cases directly support #142. Routing platform-qualified gem URLs through checkMetadataURL is a consequence of treating platform builds as listed artifacts. The PR states this as a behaviour change: an HTTP mirror now gets ErrUnsafeURL for a platform request. This is a security-relevant side effect, not unrelated work. Reviewers should confirm it is accepted, but it does not show an unrelated change.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 55e1701a-f947-4e71-888b-0ed2ae995d1f
Commits

Reviewing files that changed from the base of the PR and between 74ddb34 and 1c4efb7.

Files selected for processing: 4

  • fetch/resolver.go
  • fetch/rubygems_resolver_test.go
  • internal/rubygems/rubygems.go
  • internal/rubygems/rubygems_test.go

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

@charlie-morrison

Copy link
Copy Markdown
Contributor Author

One more consequence, found after opening this, in git-pkgs/proxy. internal/mirror/versions.go lists versions through FetchVersions for PURLs without a version. Until now a gem's platform builds came back as versions of their own (1.13.6-x86_64-linux), and the generic mirror path fetched each one through the built URL. With this change the list has only 1.13.6, so mirroring every version of pkg:gem/nokogiri would get the ruby gem and skip the platform builds.

The proxy path that reads Artifacts is fileEcosystems in internal/mirror/files.go, which has pypi and conda but not gem. Adding gem there would bring the platform builds back, selected by the platform qualifier. If you'd rather leave the version list as it was, the other option in #142 (the resolver putting the platform into the download URL) doesn't touch FetchVersions.

@andrew
andrew merged commit b97d294 into git-pkgs:main Nov 15, 2026
4 checks passed
@charlie-morrison
charlie-morrison deleted the gem-platform-artifacts branch November 16, 2026 18:23
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.

Resolver ignores the platform qualifier for gems

2 participants