Fix validate -u HTTP 400 error by removing deprecated pds:Resource registry query filters - #1658
Fix validate -u HTTP 400 error by removing deprecated pds:Resource registry query filters#1658jordanpadams wants to merge 5 commits into
Conversation
…ting sort key Remove pds:Resource.pds:type filter clauses from the registry query that no longer exist in the registry and cause HTTP 400 errors. Also update the sort key from ops:Harvest_Info.ops:harvest_date_time to ops:Label_File_Info.ops:creation_date_time. Fixes #1657 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add GetLatestJsonContextTest with 3 tests (happy path, pagination, HTTP 400 error) using a JDK HttpServer mock — no network required - Fix pre-existing NullPointerException in getLatestJsonContext() finally block when reader is null (HTTP connection fails before Scanner is created) - Add ToolInfo.setProperty() to allow overriding search URL in tests - Make getLatestJsonContext() package-private to enable direct testing Fixes #1659 Refs #1657 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
nutjob4life
left a comment
There was a problem hiding this comment.
Fantastic @jordanpadams, thank you so much.
With the help of an artificial intelligence, we've found a potential pagination issue:
The creation_date_time may not be unique in the registry and using search-after may skip records. For example, suppose the page size is 1000 and we see records like:
…
record 999 creation_date_time = 2024-01-01T12:00:00Z
record 1000 creation_date_time = 2024-01-01T12:00:00Z
record 1001 creation_date_time = 2024-01-01T12:00:00Z
record 1002 creation_date_time = 2024-01-01T12:00:00Z
If page 1 ends at record №1000 and the next request says
search-after=2024-01-01T12:00:00Z
what happens to record №1001 and №1002? It might be that the underlying API/OpenSearch has a deterministic tie-breaker; do we know?
Everything else looks copacetic though, and Maven's happy, which means: ✅
Maven details:
[INFO] Tests run: 326, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
|
Great catch, @nutjob4life — the concern is valid. The good news: The PDS Search API accepts multiple final String searchAfterKey = "ops:Label_File_Info.ops:creation_date_time,lidvid";and the I'll open a follow-up issue to track this so it doesn't get lost, and address it before the release cut.
|
…date_time Add lidvid as secondary sort key so the search-after cursor is always unique, preventing pages from skipping records that share the same creation timestamp. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|



🗒️ Summary
Remove
pds:Resource.pds:typefilter clauses from the registry search query used byvalidate -u— these resource fields no longer exist in the registry and cause HTTP 400 errors. Also updates the pagination sort key fromops:Harvest_Info.ops:harvest_date_timetoops:Label_File_Info.ops:creation_date_time.Additionally fixes a pre-existing
NullPointerExceptionin thefinallyblock ofgetLatestJsonContext()when the HTTP connection fails before theScanneris assigned.Changed files:
src/main/resources/validate.properties— simplified query to(product_class eq "Product_Context")src/main/java/gov/nasa/pds/validate/ValidateLauncher.java— updatedsearchAfterKey; fix NPE infinallyblock; makegetLatestJsonContext()package-private for testabilitysrc/main/java/gov/nasa/pds/validate/util/ToolInfo.java— addsetProperty()to support overriding search URL in testssrc/test/java/gov/nasa/pds/validate/GetLatestJsonContextTest.java— new: 3 tests using a JDKHttpServermock (happy path, pagination, HTTP 400 error)🤖 AI Assistance Disclosure
Estimated % of code influenced by AI: 90%
⚙️ Test Data and/or Report
Automated tests added in
GetLatestJsonContextTest— 3 scenarios using a local JDKHttpServermock (no network required):Product_ContextarrayAll 3 tests pass locally (
mvn test -Dtest=GetLatestJsonContextTest).♻️ Related Issues
Fixes #1657
Fixes #1659
🤓 Reviewer Checklist
Reviewers: Please verify the following before approving this pull request.
Documentation and PR Content
Security & Quality
Testing & Validation
Maintenance
🤖 Generated with Claude Code