Skip to content

Add regression test for missing_constant with whitespace suppressing min/max range errors - #1680

Open
jordanpadams wants to merge 2 commits into
mainfrom
issue_1656
Open

jordanpadams wants to merge 2 commits into
mainfrom
issue_1656

Conversation

@jordanpadams

Copy link
Copy Markdown
Member

🗒️ Summary

Adds a regression test for #1656, which reports that validate emits false warnings/errors when a missing_constant value contains leading or trailing whitespace (e.g., -1.000) and the actual field value is the numeric equivalent (-1.000). The fix for #1660 likely resolves this as well — this test case ensures #1656 stays covered going forward.

Test data (src/test/resources/github1656/):

  • test_missing_constant_whitespace.csv — 3-record delimited table; two records contain the missing-constant sentinel value -1.000, one contains a valid value 5.000
  • test_missing_constant_whitespace.xml — label with <missing_constant> -1.000</missing_constant> (leading whitespace) and Field_Statistics.minimum = 0.001, which triggers false field_value_out_of_min_max_range errors on unpatched code

Confirmed bug reproduction against v4.2.0-SNAPSHOT: 2 error.table.field_value_out_of_min_max_range errors are emitted for rows containing the missing-constant value.

🤖 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: 90%

⚙️ Test Data and/or Report

New Cucumber scenario added to src/test/resources/features/4.2.x.feature (test 1656-1):

--skip-context-validation -t {datasrc}/test_missing_constant_whitespace.xml

Expected outcome after fix: passed=1, totalErrors=0, totalWarnings=2 (only the two expected schema-related warnings matching the same pattern as test 1660-1).

Current outcome on v4.2.0-SNAPSHOT (bug reproduced):

2  error.table.field_value_out_of_min_max_range
1  warning.label.bad_schematypens
1  warning.label.missing_schematron_spec

Run with:

mvn test -Dtest=\!ReferenceIntegrityTest* -Dcucumber.filter.tags='@4.2.x'

♻️ Related Issues

Fixes #1656
Refs #1660

🤓 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).

🤖 Generated with Claude Code

…esses min/max warnings

Test case reproduces the bug where a missing_constant value with leading
whitespace (e.g. "   -1.000") is not recognized as matching the field
value "-1.000", causing false field_value_out_of_min_max_range errors.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jordanpadams
jordanpadams requested a review from a team as a code owner September 14, 2026 19:19
@jordanpadams jordanpadams added the bug Something isn't working label Sep 14, 2026
@jordanpadams jordanpadams self-assigned this Sep 14, 2026
Special constant values in labels may have leading/trailing whitespace
(e.g. <missing_constant>   -1.000</missing_constant>). The string
comparison paths in isNonConformantSpecialConstant and the numeric path
in sameContent both failed to match because they compared against the
unstripped raw XML text value.

- Add equalsStripped() helper and use it in isNonConformantSpecialConstant
  so string-based constant comparisons tolerate whitespace-padded values
- Call constant_repr.strip() at the top of sameContent() so the numeric
  comparison path (including BigDecimal parsing) also tolerates whitespace

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

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.

validate WARNs if value is below valid_minimum but equals missing_constant

1 participant