Repository navigation
Fixes #34444: stop Data Contract SLA editor emitting null numerics when cleared - #34503
detail-app[bot] wants to merge 2 commits into
Conversation
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
✅ Playwright Results — workflow succeededValidated commit ✅ 4685 passed · ❌ 0 failed · 🟡 1 flaky · ⏭️ 1 skipped · 🧰 0 lifecycle flaky PerformanceBlocking 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:
🟡 1 flaky test(s) (passed on retry)
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
08a74d0 to
663bf21
Compare
🔄 Playwright impact map auto-refreshedThis PR touched specs or UI source that changed the source→spec routing map. I regenerated 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 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 |
|
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. |
|



Detail bug report: View on Detail
Describe your changes:
Fixes #34444
I worked on the Data Contract SLA editor (
ContractSLAFormTab) because itshandleFormChangenumeric guards used>= 0, which in JavaScript admitsnull(null >= 0coerces to0 >= 0→true). antd'sInputNumberemitsnullwhen cleared, so clearing a value box while a unit stayed selected emitted a malformed SLA object such as{ maxLatency: { unit: "hour", value: null } }(likewiserefreshFrequency.interval: null,retention.period: null).replaceop setting the numeric field tonull. That op is persisted by the backend (the PATCH path runs no Bean Validation, so the@NotNullonMaxLatency.value/RefreshFrequency.interval/Retention.periodis not enforced), corrupting the stored contract in violation of its own schema.@Validcascade rejected the payload with HTTP 400, but no UI field was flagged, so the form looked valid while the save failed.Type of change:
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:
The three guards in
handleFormChange(max_latency_value,refresh_frequency_interval,retention_period) now callisNonNegativeNumeric(...). Extracting the helper also keepshandleFormChangeat cyclomatic complexity 10 (the inline!= null && >= 0form would have breached the repo'ssonarjs/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
sla, instead of emitting{ ..., value: null }.removeop (not areplace: null) when diffed against the stored contract viafast-json-patchcompare— the exact pipelineAddDataContract.handleSaveruns.0remains a valid value for all three fields (the>= 0intent is preserved); negative values are still rejected.Unit tests
openmetadata-ui/src/main/resources/ui/src/components/DataContract/ContractSLAFormTab/ContractSLAFormTab.test.tsx(newCleared numeric value guards (null-input regression)describe block, 10 cases).>= 0guards (8 fail, confirming they catch the bug) and pass after the fix; the0/negative cases stay green on both, isolating the coercion flaw precisely.Backend integration tests
Ingestion integration tests
Playwright (UI) tests
fast-json-patchcompareboundary by the new unit tests, which reproduce the exact patch shapeAddDataContract.handleSaveproduces. A live-browser Playwright e2e was considered but would have required standing up the full backend stack; the automatedcompare-level assertions provide equivalent coverage of the corruption shape.Manual testing performed
DataContractJest suite (22 suites / 490 tests) — all pass, no regressions inAddDataContract(create + update/JSON-patch flow) or sibling tabs.expect(received).toBeUndefined()—sla.maxLatencywas{ unit: 'hour', value: null }), then restored the fix and confirmed 38/38 pass.fast-json-patchcompareagainst the stored SLA, yields{"op":"remove","path":"/sla/maxLatency"}with no{"op":"replace","path":"/sla/maxLatency/value","value":null}.1.12.0-SNAPSHOTbackend 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 ofcontractSLA/maxLatency/refreshFrequencyin itsdataContract.json), so it cannot exercise the SLA PATCH/POST path. Thecompare-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
InputNumberalready visually appears empty before and after the fix.Checklist:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.Bug fix
Automatic Fixes PRs can be configured here.