Skip to content

Normalize collapsed-whitespace fields in context reference mismatch checks - #1665

Draft
jordanpadams with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-whitespace-collapsing
Draft

Normalize collapsed-whitespace fields in context reference mismatch checks#1665
jordanpadams with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-whitespace-collapsing

Conversation

Copilot AI commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Observing_System_Component/name values containing line breaks or repeated spaces were being compared verbatim against registered context names, causing false context_ref_mismatch warnings. For UTF8_Short_String_Collapsed fields, comparison should treat whitespace-equivalent values as equal.

  • Validation logic: collapse whitespace before compare

    • Updated ContextProductReferenceValidationRule to normalize both label-side and registered context values for name and type prior to case-insensitive matching.
    • Added a local normalization helper to enforce: trim + collapse internal whitespace runs to a single space.
  • Regression coverage for multiline / multi-space names

    • Added a new 4.1.x scenario (1265-1) using a fixture variant where Observing_System_Component/name includes embedded newline and repeated spaces.
    • Expected warnings remain aligned with the baseline equivalent label (no extra mismatch from whitespace-only differences).
private String collapseWhitespace(String value) {
  if (value == null) {
    return "";
  }
  return value.trim().replaceAll("\\s+", " ");
}

Co-authored-by: jordanpadams <33492486+jordanpadams@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix context reference check for whitespace collapsing Normalize collapsed-whitespace fields in context reference mismatch checks Aug 25, 2026
Copilot AI requested a review from jordanpadams August 25, 2026 20:28
| issueNumber | subtest | datasrc | args | expectation |
| 956 | 1 | "github956" | "--skip-context-validation -t {datasrc}/" | |
| 1458 | 1 | "github1458" | " -t {datasrc}/" | "summary:productValidation:passed=2,summary:productValidation:total=2,summary:totalWarnings=7,messageTypes:warning.integrity.pds4_version_mismatch=1,messageTypes:warning.label.context_ref_mismatch=5,messageTypes:warning.label.schematron=1" |
| 1265 | 1 | "github1265" | " -t {datasrc}/" | "summary:productValidation:passed=2,summary:productValidation:total=2,summary:totalWarnings=7,messageTypes:warning.integrity.pds4_version_mismatch=1,messageTypes:warning.label.context_ref_mismatch=5,messageTypes:warning.label.schematron=1" |

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@copilot move this to 4.2.x.feature

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Moved 1265-1 from 4.1.x.feature to 4.2.x.feature in commit 71dea38.

Co-authored-by: jordanpadams <33492486+jordanpadams@users.noreply.github.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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Context reference check is not collapsing whitespace

2 participants