Skip to content

Consistent error messaging for field names in query language#734

Merged
al-niessner merged 9 commits intodevelopfrom
issue_712
Apr 22, 2026
Merged

Consistent error messaging for field names in query language#734
al-niessner merged 9 commits intodevelopfrom
issue_712

Conversation

@al-niessner
Copy link
Copy Markdown
Contributor

@al-niessner al-niessner commented Mar 4, 2026

🗒️ Summary

Treat specific field names the same as wildcard field names.

🤖 AI Assistance Disclosure

  • No AI assistance used
  • AI used for light assistance (e.g., suggestions, refactoring, documentation help, minor edits)
  • AI used for moderate content generation (AI generated some code or logic, but the developer authored or heavily revised the majority)
  • AI generated substantial portions of this code

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

  • Documentation: README, Wiki, or inline documentation (Sphinx, Javadoc, Docstrings) have been updated to reflect these changes.
  • Issue Traceability: The PR is linked to a valid GitHub Issue
  • PR Title: The PR title is "user-friendly" clearly identifying what is being fixed or the new feature being added, that if you saw it in the Release Notes for a tool, you would be able to get the gist of what was done.

Security & Quality

  • SonarCloud: Confirmed no new High or Critical security findings.
  • Secrets Detection: Verified that the Secrets Detection scan passed and no sensitive information (keys, tokens, PII) is exposed.
  • Code Quality: Code follows organization style guidelines and best practices for the specific language (e.g., PEP 8, Google Java Style).

Testing & Validation

  • Test Accuracy: Verified that test data is accurate, representative of real-world PDS4 scenarios, and sufficient for the logic being tested.
  • Coverage: Automated tests cover new logic and edge cases.
  • Local Verification: (If applicable) Successfully built and ran the changes in a local or staging environment.

Maintenance

  • Backward Compatibility: Confirmed that these changes do not break existing downstream dependencies or API contracts (or that breaking changes are clearly documented).

Check that given field name in the query language is valid throwing same error when they do not.
@al-niessner al-niessner self-assigned this Mar 4, 2026
@al-niessner al-niessner requested a review from a team as a code owner March 4, 2026 19:47
@jordanpadams jordanpadams changed the title 712: consistent error messaging for field names in query language Consistent error messaging for field names in query language Mar 9, 2026
Comment thread service/src/main/java/gov/nasa/pds/api/registry/model/Antlr4SearchListener.java Outdated
Copy link
Copy Markdown
Member

@tloubrieu-jpl tloubrieu-jpl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created by mistake on this PR. I was targeting another PR.

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.
@jordanpadams
Copy link
Copy Markdown
Member

@al-niessner @tloubrieu-jpl do we have any idea why these branch actions are running in what appears to be an infinite loop?

@al-niessner
Copy link
Copy Markdown
Contributor Author

@jordanpadams Nope.

@jordanpadams
Copy link
Copy Markdown
Member

@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.

Copy link
Copy Markdown
Member

@jordanpadams jordanpadams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@tloubrieu-jpl
Copy link
Copy Markdown
Member

tloubrieu-jpl commented Apr 6, 2026

Hi @al-niessner ,

I am catching up with the registry updates.
While testing this PR with the integration test I had a 400 error with that request (from the integration tests).

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:
https://pds.nasa.gov/datastandards/documents/dd/v1/PDS4_PDS_DD_1P00.html#d5e69406

Also I was hoping we could have a more explicit error message as specified in the acceptance criteria of the ticket: the API returns a 400 error with a clear, descriptive message identifying the unknown field name (e.g., "Field 'pds:Nonexistent_Field' does not exist in the registry schema")

Is that something which can be done ?

Thanks

Al Niessner added 2 commits April 17, 2026 09:29
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.
@sonarqubecloud
Copy link
Copy Markdown

@al-niessner
Copy link
Copy Markdown
Contributor Author

@jordanpadams @tloubrieu-jpl

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.

@al-niessner al-niessner dismissed stale reviews from jordanpadams and tloubrieu-jpl April 22, 2026 17:14

completed

Copy link
Copy Markdown
Member

@tloubrieu-jpl tloubrieu-jpl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am unable to test locally quickly as I am working on something else in the same repository, but what I see looks good.

@al-niessner al-niessner merged commit a81918e into develop Apr 22, 2026
2 checks passed
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.

3 participants