Skip to content

fix(ui): keep Applications config form clean after a save when stored config has legacy keys - #38053

Merged
Rohit0301 merged 3 commits into
mainfrom
detail/bug-fix/fix-ui-keep-applications-config-form-clean-after-a-c306b9
Nov 18, 2026
Merged

Rohit0301 merged 3 commits into
mainfrom
detail/bug-fix/fix-ui-keep-applications-config-form-clean-after-a-c306b9

Conversation

@detail-app

@detail-app detail-app Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Detail bug report: View on Detail

Closes #38025

Bug

When an OpenMetadata application's stored appConfiguration carried a key the current schema no longer recognizes (a documented state on upgraded instances — the repo ships hand-written JSON_REMOVE migrations only for RdfIndexApp and DataInsightsApplication, and SearchIndexing/CacheWarmup strip such keys only at runtime without persisting the cleanup), the Applications settings modal claimed there were unsaved changes immediately after every successful save, and blocked Cancel/close/navigation with the "discard changes?" prompt despite the user having just saved.

Root cause is an asymmetry between RJSF's change and submit paths in AppConfigForm:

  • FormBuilderV1 passes omitExtraData to @rjsf/core without liveOmit, so the submit payload is pruned of schema-unknown keys but onChange data is not.
  • AppConfigForm derives isDirty by deep-comparing a currentFormData snapshot captured from onChange against a savedFormData baseline derived from the stored config.
  • After a save, the host (AppDetails.component.tsx → patchApplication → setAppData(response)) replaces the stored config with the pruned payload, so savedFormData moves — but currentFormData (still holding the legacy key) is never re-synced. isDirty stays true forever; a second Save does not clear it.

The dirty-tracking guard this bug lives in was introduced in #37904.

Fix

In AppConfigForm.tsx, reset the live-form snapshot whenever the saved baseline moves — enforcing the contract the code comment already claimed ("when a save updates the app, the baseline moves and the form reads clean again"):

const [currentFormData, setCurrentFormData] = useState<unknown>();
useEffect(() => {
  setCurrentFormData(undefined);
}, [savedFormData]);

This is the bug report's "minimal guard fix". I deliberately did not switch FormBuilderV1 to liveOmit (the alternative suggested fix): liveOmit would also fix the reported symptom but introduce a different regression — when the stored config carries a legacy key, an edit followed by a revert reads as dirty, because RJSF would prune currentFormData while getDefaultFormState still retains the legacy key in savedFormData. The reactive reset is surgical (no shared-FormBuilderV1 behavior change, so no risk to its ~10 other consumers), and resilient to failed saves by construction: the baseline only moves on a successful patch + setAppData(response), so a failed save leaves savedFormData unchanged and the form correctly stays dirty.

Testing

  • Unit tests (yarn test AppConfigForm.test.tsx): added 4 cases around the dirty-tracking contract — clean on mount with a legacy key, clean after a reverted edit with a legacy key (catches the liveOmit-only regression), clean after a save when the stored config carried a schema-unknown key (the bug repro), and stays dirty after a failed save (verifies the reset does not fire when the host leaves appData unchanged). All 11 cases in the file pass; the bug-repro case fails when the fix is reverted via git stash, confirming the RED→GREEN cycle. Full tabs/applications/ Jest suite (89 cases), AppDetails (12), useUnsaved… + UnsavedChangesPrompt (16), and FormBuilderV1 (109) all green. Coverage on AppConfigForm.tsx is 100% lines.
  • UI Checkstyle gate passed on the changed files: ESLint + Prettier + organize-imports, license header, tw-audit, tw-deprecation-guard, yarn i18n (no locale diff), yarn generate:app-docs (no generated-docs diff).
  • Typecheck / build / bundle: yarn tsc:check reports no new errors vs. baseline (only the pre-existing unrelated OMSelectWidget.tsx line). yarn build, yarn bundle:check, and yarn bundle:runtime (after installing the Playwright chromium deps) all pass.
  • End-to-end against a real backend: brought up the OpenMetadata 2.1.0-rc2 Docker stack, ran the in-repo patched UI via Vite dev against it, and produced the admin playwright/.auth/admin.json. e2e/Features/SettingsUnsavedChanges.spec.ts (6 tests, including "an untouched Applications config form leaves without asking") and e2e/Features/ApplicationsSettingsModal.spec.ts (8 tests, including "saves configuration from the footer with hints toggled on") both pass — no regression in the existing Applications save flow. make playwright_affected routes this change to ApplicationsSettingsModal.spec.ts.
  • Bug-precise Playwright regression (not versioned): I attempted to add a new spec that seeds the bug-state (a stored config with a schema-unknown key) via page.route against the GET response, then exercises edit → save → Cancel and asserts no unsaved-changes popover. The published 2.1.0-rc2 backend's Jackson rejects appConfiguration carrying a schema-unknown key on read with HTTP 400 Unrecognized field, so the bug-inducing state is unreachable via this server's API for DataRetentionApplication. A page.route-based mock of the GET + PATCH was brittle (Playwright's LIFO route priority shadowed the GET matcher with the PATCH matcher, timing out unrelated navigation), so I reverted the speculative spec rather than commit a flaky test. The authoritative bug-state reproduction lives in the Jest unit test above, which renders real @rjsf/core 5.24.13 and fails identically in the bug-state.

Automatic Fixes PRs can be configured here.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no blocking issues were found.

Summary

The PR clears stale unsaved-change warnings after an application configuration is saved and makes Cancel return to the applications list.

  • Saved application configs leave the form clean, even when they contain legacy keys.
  • Cancel returns from an application’s configuration to the Applications list.

The previous schema-change finding is fixed. No new actionable issues were found.

Reviews (3) · Last reviewed commit: "fix(ui): return to the Applications list..." · Reviewed by Greptile

@detail-app
detail-app Bot requested a review from a team as a code owner November 18, 2026 04:32
@detail-app
detail-app Bot requested review from Rohit0301 and karanh37 November 18, 2026 04:32
…ange, not schema change

A late-loading schema (MCP tool names) recomputed the baseline and cleared an
in-progress edit, so Cancel could discard it without prompting.
…s cancelled

Matches the other settings forms: Cancel (or Discard from the unsaved-changes
prompt) leaves the form instead of remounting it in place.
@Rohit0301
Rohit0301 enabled auto-merge (squash) November 18, 2026 05:44
@Rohit0301
Rohit0301 disabled auto-merge November 18, 2026 05:53
@Rohit0301
Rohit0301 merged commit bbc3497 into main Nov 18, 2026
54 checks passed
@Rohit0301
Rohit0301 deleted the detail/bug-fix/fix-ui-keep-applications-config-form-clean-after-a-c306b9 branch November 18, 2026 05:59
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.

[Detail Bug] UI: Applications settings modal shows unsaved-changes prompt immediately after saving when stored config has legacy keys

3 participants