Skip to content

Extract portable Maven metadata transformations - #811

Open
simonchrz wants to merge 1 commit into
git-pkgs:mainfrom
simonchrz:refactor/metadata-maven
Open

simonchrz wants to merge 1 commit into
git-pkgs:mainfrom
simonchrz:refactor/metadata-maven

Conversation

@simonchrz

Copy link
Copy Markdown
Contributor

Part of #501, the Maven step.

As in #612 for npm, the Maven metadata transformations move out of internal/handler into internal/metadata/maven:

  • Filter, which removes versions in cooldown from an artifact's maven-metadata.xml and points <latest> and <release> at the newest versions left, editing the document in place
  • ParseMetadata, Metadata and Without, which read the version list, <latest>, <release> and <lastUpdated> with their offsets and take versions out
  • Coordinates, UsableVersion and PackagePURL

The package takes its inputs explicitly in Options: the cooldown policy, the time cooldown is evaluated at, and a PublishTime lookup. It reports versions cooldown holds back through OnWithheld, which the handler logs and records for the default repository as before. It doesn't depend on handler.Proxy.

Publish times stay in the handler: the versions table, else the .pom's Last-Modified. Filter asks for them from the newest version back and stops at the first that is old enough, and asks for none when <lastUpdated> is out of cooldown, so Maven Central sees the same requests as before.

What stays in the handler: fetching, the rewrite cache, the checksum files served beside the metadata, the publish-time lookup, and downloads with their cooldown check. The handler's functions stay as thin wrappers, so the handler tests run unchanged against the real routes.

Cooldown in the filter is checked with Evaluate at one EvaluatedAt instead of IsAllowed per version, as in internal/metadata/npm. The handler passes time.Now(), so results are the same unless a filter runs across a cooldown boundary.

Portability: GOOS=wasip1 GOARCH=wasm go build ./internal/metadata/maven works. imports_test.go fails on any non-standard import outside an allowlist (cooldown, purl, vers, packageurl-go, internal/packageurl) and on net, net/http, log/slog or database/sql.

New tests in internal/metadata/maven cover versions held back from the end of the list with lookups stopping at the first old enough, <lastUpdated> out of cooldown skipping all lookups and an unreadable one, SNAPSHOT versions and versions without a time, a failed lookup, a missing or disabled policy, directories that aren't an artifact's and metadata without a version list, malformed XML and other charsets, <latest> and <release> kept, moved or dropped (including CRLF lines), and the coordinate and version helpers. They were mutation-checked, as was the handler's wiring. There are no Maven benchmarks to compare. go test ./... and golangci-lint run ./... pass.

The maven-metadata.xml cooldown filter moves out of internal/handler
into internal/metadata/maven: parsing the version list, <latest>,
<release> and <lastUpdated> with their offsets, removing versions in
cooldown in place, and the coordinate and version helpers. The package
takes the cooldown policy, the time it is evaluated at and a publish-time
lookup explicitly, and reports held-back versions through OnWithheld.
Publish times still come from the handler, looked up only as far as the
filter asks. Cooldown is checked with Evaluate at one EvaluatedAt.
@coderabbitai

coderabbitai Bot commented Nov 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 34 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

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: 1dc9e9c8-5b7c-46af-8180-758305fc640f
Commits

Reviewing files that changed from the base of the PR and between be51120 and 906ff86.

Files selected for processing: 4

  • internal/handler/maven_cooldown.go
  • internal/metadata/maven/imports_test.go
  • internal/metadata/maven/metadata.go
  • internal/metadata/maven/metadata_test.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

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.

1 participant