Skip to content

maven: decode the version from the Solr v field on core=gav responses - #82

Merged
andrew merged 2 commits into
git-pkgs:mainfrom
frankreyesgarcia:fix/maven-gav-version-parsing
Sep 4, 2026
Merged

maven: decode the version from the Solr v field on core=gav responses#82
andrew merged 2 commits into
git-pkgs:mainfrom
frankreyesgarcia:fix/maven-gav-version-parsing

Conversation

@frankreyesgarcia

Copy link
Copy Markdown
Contributor

Fixes #49.

FetchVersions and FetchPackage query Maven Central with core=gav, where each result document carries the concrete version in v:

{"g":"org.apache.maven","a":"maven-core","v":"3.9.11","timestamp":1757293341000}

searchDoc.Version was tagged json:"latestVersion" — a field that only exists on the default (non-gav) core, where a document aggregates an artifact. Decoding a real core=gav response therefore left Version empty, so FetchVersions returned entries with blank Number, and FetchPackage/FetchMaintainers resolved the effective POM against an empty version.

The existing tests encode a searchDoc struct into the mock response and decode it with the same struct, so the wrong field name round-tripped and was never exercised.

Change

  • searchDoc.Versionjson:"v".
  • New TestFetchVersionsParsesRealSolrGavShape feeds the raw JSON the search API actually returns and asserts non-empty versions through FetchVersions.

Before / after (against real Maven Central)

before:  FetchVersions("com.google.guava:guava")  -> n=150, every Number == ""
after:   FetchVersions("com.google.guava:guava")  -> n=150, Number populated, contains "33.0.0-jre"
         FetchVersions("org.slf4j:slf4j-api")     -> n=106, Number populated, contains "2.0.13"

Full go test ./... passes.

🤖 Generated with Claude Code

…ion"

FetchVersions and FetchPackage query the Maven Central search API with
core=gav, where each document is one groupId:artifactId:version and the
version is in the "v" field. searchDoc.Version was tagged
json:"latestVersion" - a field that only exists on the default (non-gav)
core, where a document aggregates an artifact - so every FetchVersions
result came back with Number == "".

The existing tests encode a searchDoc struct into the mock response and
decode it with the same struct, so the field name never mattered; added
TestFetchVersionsParsesRealSolrGavShape which feeds the raw JSON the API
actually returns.

Before (against real Solr):
  guava      -> n=150, all Number == ""
After:
  guava      -> n=150, Number populated, contains "33.0.0-jre"

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@frankreyesgarcia
frankreyesgarcia force-pushed the fix/maven-gav-version-parsing branch from 38f96cb to f30fd24 Compare September 4, 2026 08:52
@andrew
andrew merged commit 5019ed9 into git-pkgs:main Sep 4, 2026
2 checks passed
@algomaster99

algomaster99 commented Sep 4, 2026

Copy link
Copy Markdown

@andrew e4cbda5 (this PR) did you automate this commit or did you trim it manually? I like this if it is automated.

frankreyesgarcia added a commit to frankreyesgarcia/yul that referenced this pull request Sep 9, 2026
RegistryExistenceChecker (git-pkgs/enrichment's registries client, which
queries Maven Central's Solr search index) can return found/not-found
inconsistently for the same coordinate shortly after a version is
published - observed as a real false positive ("hallucinated version")
against a genuinely published release while benchmarking yul against real
projects. Existence now retries a registries.ErrNotFound, and separately a
queried version missing from an otherwise-real version list, once (300ms
backoff) before trusting either as a real miss.

Bumped github.com/git-pkgs/registries to v0.9.1, which includes upstream
PR git-pkgs/registries#82 fixing a related (but distinct) bug: versions
v0.8.1 and earlier decoded the wrong JSON field for Maven's core=gav Solr
response shape, so every returned version came back as an empty string.

Removed the old fixture-based hallucination benchmark (README/fixtures/
run.sh) - it fed crafted payloads straight to the yul binary and never
touched a real registry, so it couldn't have caught either bug.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.

maven: decode versions from core=gav responses

3 participants