Skip to content

Fixes #34444: stop Data Contract SLA editor emitting null numerics when cleared - #34503

Closed
detail-app[bot] wants to merge 2 commits into
mainfrom
detail/bug-fix/fixes-34444-stop-data-contract-sla-editor-emitting-297d1d
Closed

detail-app[bot] wants to merge 2 commits into
mainfrom
detail/bug-fix/fixes-34444-stop-data-contract-sla-editor-emitting-297d1d

Conversation

@detail-app

@detail-app detail-app Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Detail bug report: View on Detail

Describe your changes:

Fixes #34444

I worked on the Data Contract SLA editor (ContractSLAFormTab) because its handleFormChange numeric guards used >= 0, which in JavaScript admits null (null >= 0 coerces to 0 >= 0 → true). antd's InputNumber emits null when cleared, so clearing a value box while a unit stayed selected emitted a malformed SLA object such as { maxLatency: { unit: "hour", value: null } } (likewise refreshFrequency.interval: null, retention.period: null).

  • On edit (PATCH) this produced a JSON-Patch replace op setting the numeric field to null. That op is persisted by the backend (the PATCH path runs no Bean Validation, so the @NotNull on MaxLatency.value / RefreshFrequency.interval / Retention.period is not enforced), corrupting the stored contract in violation of its own schema.
  • On create (POST) the @Valid cascade rejected the payload with HTTP 400, but no UI field was flagged, so the form looked valid while the save failed.

Type of change:

  • Bug fix

High-level design:

N/A — small change.

The root cause is a one-line coercion flaw per guard. The fix extracts a small helper and reuses it for all three numeric fields, keeping the original "allow zero, reject negatives" intent:

// `null >= 0` is `true` in JS — check `!= null` first so a cleared field
// drops its SLA sub-object instead of emitting `{ value: null }`.
const isNonNegativeNumeric = (value: number | null | undefined): boolean =>
  value != null && value >= 0;

The three guards in handleFormChange (max_latency_value, refresh_frequency_interval, retention_period) now call isNonNegativeNumeric(...). Extracting the helper also keeps handleFormChange at cyclomatic complexity 10 (the inline != null && >= 0 form would have breached the repo's sonarjs/cyclomatic-complexity ≤ 10 rule). No backend or schema changes — the fix closes the corruption path at the UI emit boundary, which covers both the POST 400 and the PATCH persistence paths.

Tests:

Use cases covered

  • Clearing an SLA numeric field (maxLatency value / refreshFrequency interval / retention period) while its unit Select stays selected drops the sub-object from the emitted sla, instead of emitting { ..., value: null }.
  • A cleared numeric produces a safe JSON-Patch remove op (not a replace: null) when diffed against the stored contract via fast-json-patch compare — the exact pipeline AddDataContract.handleSave runs.
  • 0 remains a valid value for all three fields (the >= 0 intent is preserved); negative values are still rejected.

Unit tests

  • I added unit tests for the changed logic.
  • Files updated: openmetadata-ui/src/main/resources/ui/src/components/DataContract/ContractSLAFormTab/ContractSLAFormTab.test.tsx (new Cleared numeric value guards (null-input regression) describe block, 10 cases).
  • The new tests fail on the pre-fix >= 0 guards (8 fail, confirming they catch the bug) and pass after the fix; the 0/negative cases stay green on both, isolating the coercion flaw precisely.

Backend integration tests

  • Not applicable (no backend API changes).

Ingestion integration tests

  • Not applicable (no ingestion changes).

Playwright (UI) tests

  • Not applicable — the regression is fully covered at the fast-json-patch compare boundary by the new unit tests, which reproduce the exact patch shape AddDataContract.handleSave produces. A live-browser Playwright e2e was considered but would have required standing up the full backend stack; the automated compare-level assertions provide equivalent coverage of the corruption shape.

Manual testing performed

  • Ran the full DataContract Jest suite (22 suites / 490 tests) — all pass, no regressions in AddDataContract (create + update/JSON-patch flow) or sibling tabs.
  • Reverted the guards byte-for-byte to HEAD and re-ran the suite to confirm the new tests fail (expect(received).toBeUndefined() — sla.maxLatency was { unit: 'hour', value: null }), then restored the fix and confirmed 38/38 pass.
  • Verified the emitted SLA, fed to fast-json-patch compare against the stored SLA, yields {"op":"remove","path":"/sla/maxLatency"} with no {"op":"replace","path":"/sla/maxLatency/value","value":null}.
  • A live end-to-end PATCH smoke test against a running server could not be run: no server was available and the matching 1.12.0-SNAPSHOT backend image is not published to the Collate registry (manifest unknown: manifest unknown); the only pullable server tag (1.8.2) predates the SLA feature entirely (0 occurrences of contractSLA/maxLatency/refreshFrequency in its dataContract.json), so it cannot exercise the SLA PATCH/POST path. The compare-level unit tests above provide the equivalent network-shape verification.

UI screen recording / screenshots:

Not applicable — the change is to form-value emission logic with no visible UI delta; the cleared InputNumber already visually appears empty before and after the fix.

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • My PR is linked to a GitHub issue via Fixes #<issue-number> above.
  • I have commented on my code, particularly in hard-to-understand areas.
  • For UI changes: I attached a screen recording and/or screenshots above.
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.

Bug fix

  • I have added a test that covers the exact scenario we are fixing. For complex issues, comment the issue number in the test for future reference.

Automatic Fixes PRs can be configured here.

@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

✅ Playwright Results — workflow succeeded

Validated commit 08a74d03739983242269932e89766b882496393b in Playwright run 36970416010, attempt 1.

✅ 4685 passed · ❌ 0 failed · 🟡 1 flaky · ⏭️ 1 skipped · 🧰 0 lifecycle flaky

Performance

Blocking targets: ✅ met · Optimization targets: 🟡 in progress

Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting.

🕒 Full workflow signal wall (to summary) 1h 42m 33s

⏱️ Max setup 4m 32s · max shard execution 19m 39s · max shard-job elapsed before upload 23m 36s · reporting 13s

🌐 222.81 requests/attempt · 2.20 app boots/UI scenario · 41.14% common-shard skew

Optimization targets still in progress:

  • Common shard skew was 41.14% (convergence target: at most 15%).
  • Browser traffic was 222.81 requests per attempt (convergence target: fewer than 200).
  • Application boot ratio was 2.2 per UI scenario (10952 boots / 4974 scenarios; convergence target: at most 1).
Shard Passed Failed Flaky Skipped Lifecycle failed Lifecycle flaky
✅ Shard advanced-search-01 65 0 0 0 0 0
✅ Shard advanced-search-02 65 0 0 0 0 0
✅ Shard chromium-01 148 0 0 0 0 0
✅ Shard chromium-02 128 0 0 0 0 0
✅ Shard chromium-03 145 0 0 0 0 0
✅ Shard chromium-04 147 0 0 0 0 0
✅ Shard chromium-05 177 0 0 0 0 0
✅ Shard chromium-06 186 0 0 0 0 0
✅ Shard chromium-07 131 0 0 0 0 0
✅ Shard chromium-08 173 0 0 0 0 0
✅ Shard chromium-09 142 0 0 0 0 0
✅ Shard chromium-10 171 0 0 0 0 0
✅ Shard chromium-11 137 0 0 0 0 0
✅ Shard chromium-12 227 0 0 0 0 0
✅ Shard chromium-13 142 0 0 0 0 0
✅ Shard chromium-14 164 0 0 0 0 0
✅ Shard chromium-15 179 0 0 0 0 0
✅ Shard chromium-16 162 0 0 0 0 0
✅ Shard chromium-17 147 0 0 0 0 0
✅ Shard chromium-18 159 0 0 0 0 0
🟡 Shard chromium-19 163 0 1 0 0 0
✅ Shard chromium-20 146 0 0 0 0 0
✅ Shard chromium-21 136 0 0 0 0 0
✅ Shard chromium-22 156 0 0 0 0 0
✅ Shard chromium-23 156 0 0 1 0 0
✅ Shard chromium-24 177 0 0 0 0 0
✅ Shard chromium-25 156 0 0 0 0 0
✅ Shard chromium-26 153 0 0 0 0 0
✅ Shard data-asset-rules-01 65 0 0 0 0 0
✅ Shard domain-isolation-01 16 0 0 0 0 0
✅ Shard global-state-01 34 0 0 0 0 0
✅ Shard import-export-01 84 0 0 0 0 0
✅ Shard import-export-02 68 0 0 0 0 0
✅ Shard ingestion-01 41 0 0 0 0 0
✅ Shard ingestion-02 52 0 0 0 0 0
✅ Shard reindex-01 41 0 0 0 0 0
✅ Shard search-01 17 0 0 0 0 0
✅ Shard search-rbac-01 29 0 0 0 0 0
🟡 1 flaky test(s) (passed on retry)
  • Pages/CustomProperties.spec.ts › String (shard chromium-19, 1 retry)

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

@detail-app detail-app Bot added the safe to test Add this label to run secure Github workflows on PRs label Oct 2, 2026
@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 77%
77.33% (124318/160758) 63.59% (77394/121702) 65.01% (25927/39880)

@detail-app
detail-app Bot force-pushed the detail/bug-fix/fixes-34444-stop-data-contract-sla-editor-emitting-297d1d branch from 08a74d0 to 663bf21 Compare October 13, 2026 06:56
@github-actions

Copy link
Copy Markdown
Contributor

🔄 Playwright impact map auto-refreshed

This PR touched specs or UI source that changed the source→spec routing map. I regenerated .github/playwright/impact-map.generated.json and pushed the diff to this branch.

- source entries: 922 → 923
- 1 added, 0 removed, 1 changed spec-list

New source→spec entries:
  openmetadata-ui/src/main/resources/ui/src/components/DataQuality/AddDataQualityTest/components/TestCaseFormDrawer.tsx

Entries whose spec list changed:
  openmetadata-ui/src/main/resources/ui/src/components/Explore/EntitySummaryPanel/EntitySummaryPanel.component.tsx

What is this file? It is the auto-generated half of Playwright's PR planner. It routes "if source X changes, run specs Y" by walking spec imports and cross-referencing getByTestId strings. Hand-authored routing in impact-map.json always wins on conflict.

What if I want to regenerate locally instead? Run this before pushing your next change to skip the bot commit:

python3 .github/scripts/generate_playwright_impact_map.py
git add .github/playwright/impact-map.generated.json
git commit --amend --no-edit  # or a separate commit

@shrabantipaul-collate

Copy link
Copy Markdown
Contributor

Closing: #35217 (merged 2026-10-13) rewrote ContractSLAFormTab onto react-hook-form plus the core Input type="number". A cleared field now gives '', toNonNegative maps that to undefined, and the SLA sub-object is dropped, so main no longer emits value: null. I checked this against main.

@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Detail Bug] Data Contract SLA editor emits null numeric values when cleared, causing PATCH to persist invalid SLA

1 participant