Consistent error messaging for field names in query language#734
Consistent error messaging for field names in query language#734al-niessner merged 9 commits intodevelopfrom
Conversation
Check that given field name in the query language is valid throwing same error when they do not.
change requested
sonarqube made me do it
silly sonarqube is just making the code worse not better. runtimeexception is the correct answer, but this holds truth in that if the state of the system is not repaired, the same error will continue to occur.
|
@al-niessner @tloubrieu-jpl do we have any idea why these branch actions are running in what appears to be an infinite loop? |
|
@jordanpadams Nope. |
|
@al-niessner when you have a chance, can you please try to debug what is going on with the integration tests? We cannot merge any of these updates without the integration tests integrating successfully or at least understand why it is hanging. |
jordanpadams
left a comment
There was a problem hiding this comment.
Review
🐛 Bug — Wrong collection checked in non-wildcard branch
This is the most critical issue. The condition checks this.fieldNames (the output list being assembled) instead of this.knownFieldNames (the valid fields fetched from OpenSearch):
// BUGGY — this.fieldNames starts empty, so this will ALWAYS be false
// and throw for every specific field name on first use
if (this.fieldNames.contains(fn)) {
this.fieldNames.add(fn);
} else {
throw new ParseCancellationException(...);
}Should be:
if (this.knownFieldNames.contains(fn)) {
this.fieldNames.add(fn);
} else {
throw new ParseCancellationException(...);
}As written, every specific (non-wildcard) field name query will throw a ParseCancellationException on the first call since fieldNames is always empty at that point.
🐛 Typo in error message
throw new ParseCancellationException("The request '" + fieldname + "' does match any field names in the LDD.");"does match" should be "does not match" — the message currently says the opposite of what it means.
⚠️ Behavior change: IllegalStateException vs. silent failure
Previously, if OpenSearch was unreachable during wildcard expansion, the error was logged and execution continued (wildcarding silently wouldn't work). Now it throws IllegalStateException for all queries. This is a potentially breaking change worth calling out explicitly if intentional.
⚠️ Inconsistency with issue #712 acceptance criteria (now resolved)
The acceptance criteria in #712 had a conflict on what to return when a field does not exist in the schema — "0 results" in one place, "400 error" in another. I've updated #712 to consistently require a 400 with a clear, descriptive error message for non-existent fields, which aligns with this PR's intent. The two bugs above just need to be fixed for this implementation to match.
… typo - Check knownFieldNames (valid fields from OpenSearch) instead of fieldNames (the output list being assembled) when validating specific field names; the previous logic always threw since fieldNames starts empty - Fix error message: "does match" -> "does not match" Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Hi @al-niessner , I am catching up with the registry updates. curl --location 'http://localhost:8081/products?q=(pds%3APrimary_Result_Summary.pds%3Aprocessing_level%20eq%20%22Derived%22)&limit=10' It sounds like a side effect from the update you have made but this field exists in the PDS4 information model: Also I was hoping we could have a more explicit error message as specified in the acceptance criteria of the ticket: Is that something which can be done ? Thanks |
1. version lexer was built with did not match runtime version. caused null pointer error deep in setting up antlr long before any string was being parsed. 2. using wrong field name to search ldd. converted to open search style too soon. finds it, but does not return the desired response.
|
|
Give me a thumbs up and I will merge it. Once merged, make a PR and do all of the bumps. Note: need to merge NASA-PDS/registry#505 at the same time. |
completed
tloubrieu-jpl
left a comment
There was a problem hiding this comment.
I am unable to test locally quickly as I am working on something else in the same repository, but what I see looks good.



🗒️ Summary
Treat specific field names the same as wildcard field names.
🤖 AI Assistance Disclosure
Estimated % of code influenced by AI: ___ %
⚙️ Test Data and/or Report
Automated tests should work as they cover this code block already.
♻️ Related Issues
#712
🤓 Reviewer Checklist
Reviewers: Please verify the following before approving this pull request.
Documentation and PR Content
Security & Quality
Testing & Validation
Maintenance