Skip to content

fix(retrieval): keep final release in Oxford-comma version lists - #234

Open
detail-app[bot] wants to merge 1 commit into
devfrom
detail/bug-fix/fix-retrieval-keep-final-release-in-oxford-comma-v-1cbc73
Open

detail-app[bot] wants to merge 1 commit into
devfrom
detail/bug-fix/fix-retrieval-keep-final-release-in-oxford-comma-v-1cbc73

Conversation

@detail-app

@detail-app detail-app Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Detail bug report: View on Detail

Closes #221

Bug

QueryVersionExtractor.extractVersionNumbers parses Java release tokens from learner queries for version-evidence retrieval, source-record labelling, and guided-lesson docSet scoping. Its shorthand comparison-chain regex consumed exactly one connector per lookingAt() step, so an Oxford-comma enumeration ending in , and <digit> put two connectors in sequence: the comma matched, the next token was and (not a digit), and the chain returned — silently dropping the final requested release.

  • extractVersionNumbers("Java SE 21, 25, and 26") returned [21, 25], dropping 26 — one of the three indexed Oracle Java releases.
  • The bug was narrow to the Oxford-comma trailing conjunction; the non-Oxford form (Java 21, 22 and 25) and the all-comma form (Java 21, 22, 25) already parsed correctly.
  • Impact: the dropped release lost its dedicated docVersions=[release] retrieval constraint and its requestedVersions="..." request-anchor label across all three callers (RetrievalService, ChatService, GuidedLearningService), none of which re-derive versions downstream.

Fix

Widen the comma connector alternative in SHORTHAND_VERSION_PATTERN (QueryVersionExtractor.java:17-19) to optionally span , and in a single step:

"^\\s*(?:,(?:\\s*and\\b)?|and\\b|vs(?:\\.|\\b)|versus\\b|\\+|/|&)\\s*(\\d{1,3})\\b"

The optional (?:\\s*and\\b)? group only fires after a comma, so single-connector chains (/, vs, vs., versus, +, &, bare and) are untouched. The isPlausibleJavaRelease(>= 8) guard still absorbs low-count tails (Java 21, and 2 examples ends the chain at 2), matching the existing lone-and behavior.

Testing

  • Added one focused regression-guard test (extractsOxfordCommaEnumerationWithoutDroppingFinalRelease) pinning the Oxford-comma form, a longer 4-release chain, and the two adjacent forms (all-comma, non-Oxford and) that must remain unchanged.
  • Existing QueryVersionExtractorTest suite (7/7), plus the three downstream consumer suites — RetrievalServiceTest (40), ChatServiceTest (7), GuidedLearningServiceCitationTest (11) — all pass with no outcome changes.
  • Compile, Spotless formatting, PMD, and SpotBugs are clean.
  • Ran the full CI-equivalent lane: make test (18 shell contract tests + full unit suite), make build (frontend production build + gradlew build -x test), and make lint (ast-grep Java rules, Ruby SSOT checker, frontend oxlint/eslint/svelte-check, backend SpotBugs/PMD) — all green.
  • Verified end-to-end via an ephemeral JShell probe against compiled classes: extractVersionNumbers("Java SE 21, 25, and 26") now returns [21, 25, 26], and DocsSourceRegistry.javaApiDocumentationSourcesForReleases(...) now resolves 26:java/java26-complete (previously absent).

Automatic Fixes PRs can be configured here.

The shorthand comparison-chain regex consumed exactly one connector per
step, so an Oxford-comma enumeration ending in ", and <digit>" put two
connectors in sequence; the comma matched, the next token was "and" not a
digit, and the chain returned — silently dropping the final requested
release (e.g. "Java SE 21, 25, and 26" extracted as [21, 25]).

- widen the comma connector alternative to optionally span ", and" in one
  lookingAt() step so the final release is collected before the chain ends
- single-connector chains (/, vs, +, &, bare and) stay untouched: the
  optional group only fires after a comma
@detail-app
detail-app Bot requested a review from WilliamAGH September 6, 2026 13:59
@detail-app detail-app Bot added the bug Something isn't working label Sep 6, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Detail Bug] Retrieval: Oxford-comma Java version lists drop the final requested release

1 participant