Fix NaN incorrectly rejected as invalid value for ASCII_String table fields#1532
Fix NaN incorrectly rejected as invalid value for ASCII_String table fields#1532jordanpadams wants to merge 1 commit intomainfrom
Conversation
…fields Closes #956 Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
nutjob4life
left a comment
There was a problem hiding this comment.
Code delta: ✓
Maven tests: ✓
Approval: ✅
Maven details:
293 scenarios (293 passed)
879 steps (879 passed)
11m 51.843s
Mar 19, 2026 6:35:14 PM org.junit.platform.launcher.core.DiscoveryIssueNotifier logIssues
WARNING: TestEngine with ID 'cucumber' encountered a non-critical issue during test discovery:
(1) [WARNING] Discovering tests using the cucumber.features property. Other discovery selectors are ignored!
This is a work around for the limited JUnit 5 support in Maven and Gradle. Please request/upvote/sponsor/ect better support for JUnit 5 discovery selectors. For details see: https://github.com/cucumber/cucumber-jvm/pull/2498
If you are using the JUnit 5 Suite Engine, Platform Launcher API or Console Launcher you should not use this property. Please consult the JUnit 5 documentation on test selection.
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 711.9 s -- in io.cucumber.junit.platform.engine.CucumberTestEngine
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 25, Failures: 0, Errors: 0, Skipped: 23
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
There was a problem hiding this comment.
Pull request overview
Fixes a table-field validation false positive where the literal string "NaN" was rejected for ASCII_String table fields, and adds a regression test dataset to reproduce issue #956.
Changes:
- Update
FieldValueValidator.checkType()to skip the Inf/NaN guard for string-typed fields. - Add Cucumber coverage and associated
github956test fixtures (PDS4 XML + PDS3 label + CSV).
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main/java/gov/nasa/pds/tools/validate/content/table/FieldValueValidator.java | Adjusts Inf/NaN rejection logic to permit string fields. |
| src/test/resources/features/4.1.x.feature | Adds a new Scenario Outline example for issue #956. |
| src/test/resources/github956/fsb_01500_rhk_xib_85s238_v1.xml | Adds a PDS4 label fixture describing an ASCII_String delimited table. |
| src/test/resources/github956/fsb_01500_rhk_xib_85s238_v1.lbl | Adds a PDS3 supplemental label fixture used by the test dataset. |
| src/test/resources/github956/fsb_01500_rhk_xib_85s238_v1.csv | Adds the CSV fixture containing "NaN" values in string fields. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // String types that accept any string value, including "NaN" (issue #956) | ||
| private static List<FieldType> stringTypes = Arrays.asList( | ||
| FieldType.ASCII_STRING); |
There was a problem hiding this comment.
stringTypes is a mutable, non-final static collection. Since it’s used as a constant for type classification, make it static final and preferably an immutable Set (e.g., EnumSet) to avoid accidental modification and to make membership checks clearer.
| @4.1.x | ||
| Examples: | ||
| | issueNumber | subtest | datasrc | args | expectation | | ||
| | 956 | 1 | "github956" | "--skip-context-validation -t {datasrc}/" | | No newline at end of file |
There was a problem hiding this comment.
The Examples table row is not aligned with the header (missing the expected indentation and leading |). As written, Gherkin will not parse this as a table row for the Scenario Outline examples.
| | 956 | 1 | "github956" | "--skip-context-validation -t {datasrc}/" | | | |
| | 956 | 1 | "github956" | "--skip-context-validation -t {datasrc}/" | | |
| RECORD_TYPE = STREAM | ||
| RECORD_BYTES = 85 | ||
| FILE_RECORDS = 116 | ||
| ^SPREADSHEET = "FSB_01500_RHK_XIB_85S238_V1.CSV" |
There was a problem hiding this comment.
The PDS3 label points ^SPREADSHEET to an uppercase filename ("FSB_01500_RHK_XIB_85S238_V1.CSV"), but the actual CSV added in this test data directory is lowercase. On case-sensitive filesystems this can break any logic that follows this pointer to locate the data file; consider matching the on-disk filename exactly (or aligning both to a consistent case).
| ^SPREADSHEET = "FSB_01500_RHK_XIB_85S238_V1.CSV" | |
| ^SPREADSHEET = "fsb_01500_rhk_xib_85s238_v1.csv" |
| "Mini-RF Housekeeping Parameters File" | ||
| "Characters per entry","85.","counts" | ||
| "Header entries per file","9.","counts" | ||
| "Data entries per record","30.","counts" | ||
| "Records in this file","116.","records" | ||
| "File format version number","1.1000000000","version" | ||
| "File creation time","2010-286T22:50:18.294","UTC" | ||
| "Collection Start Time","2009-071T14:11:25.000","UTC" | ||
| "Collection Stop Time","2009-071T14:14:54.000","UTC" | ||
| "Record Sequence Count","1.","counts" | ||
| "Record Start Time","2009-071T14:11:25.000","UTC" | ||
| "MSR RX FPGA DIE DG-C","NaN","Degrees C" |
There was a problem hiding this comment.
This test fixture CSV adds ~3.5k lines of data, which increases repo size and can slow test checkout/execution. If the scenario only needs to prove that an ASCII_String field can contain the literal "NaN", consider reducing the CSV to the smallest representative subset that still reproduces the issue.
| LOG.debug("checkType:value,type:after [{}],[{}]", value, type); | ||
|
|
||
| if (SpecialConstantChecker.isInfOrNan(value) && !realTypes.contains(type)) { | ||
| if (SpecialConstantChecker.isInfOrNan(value) && !realTypes.contains(type) && !stringTypes.contains(type)) { |
There was a problem hiding this comment.
The NaN/Inf guard skips only ASCII_STRING, but this method also supports FieldType.UTF8_STRING later in the same chain. As a result, a UTF8_String field containing "NaN" would still throw "NaN" is not allowed. Consider treating all string field types as exempt from the Inf/NaN check (e.g., include UTF8_STRING here, and ideally centralize string-type membership in a single set).
| if (SpecialConstantChecker.isInfOrNan(value) && !realTypes.contains(type) && !stringTypes.contains(type)) { | |
| // Treat all string field types (including UTF8_STRING) as exempt from the Inf/NaN check. | |
| final boolean isStringType = | |
| stringTypes.contains(type) | |
| || FieldType.UTF8_STRING.getXMLType().equals(type.getXMLType()); | |
| if (SpecialConstantChecker.isInfOrNan(value) && !realTypes.contains(type) && !isStringType) { |
🗒️ Summary
FieldValueValidatorwas incorrectly throwing a data type mismatch error when a table field with data typeASCII_Stringcontained the string value"NaN". The check atFieldValueValidator.checkType()was designed to reject NaN/Inf values for non-floating-point numeric types, but it failed to account for string types where any string — including"NaN"— is valid.Fix: Added
ASCII_Stringto astringTypeslist and updated the NaN/Inf guard to skip the check when the field type is a string type.🤖 AI Assistance Disclosure
Estimated % of code influenced by AI: 60%
⚙️ Test Data and/or Report
Cucumber test added in
src/test/resources/features/4.1.x.featurewith tag@4.1.x. Test data (real-world Chandrayaan-1 Mini-RF housekeeping CSV withASCII_Stringfields containingNaNvalues) placed insrc/test/resources/github956/.Result: 1 scenario passed.
♻️ Related Issues
Fixes #956
🤓 Reviewer Checklist
Reviewers: Please verify the following before approving this pull request.
Documentation and PR Content
Security & Quality
Testing & Validation
Maintenance