OpenMetadata icon indicating copy to clipboard operation
OpenMetadata copied to clipboard

fix(columns): preserve existing description on partial column update

Open Vishnuujain opened this issue 5 months ago • 7 comments

Problem

PUT /api/v1/columns/name/{fqn} treated a blank description/displayName as "delete": applyColumnUpdates set the field to null on any empty value. A partial column update that omitted the field (e.g. editing one nested column) therefore wiped existing descriptions on sibling/child columns of a struct — silent data loss.

Fix

  • Server: blank/absent description and displayName now mean "no change". Clearing is explicit via new removeDescription / removeDisplayName flags, mirroring the existing removeConstraint pattern. applyColumnUpdates made package-private static for unit testing.
  • UI: the column-update API wrappers (updateTableColumn / updateDataModelColumn) normalize a user-cleared blank field into the matching removeX flag in one place (normalizeColumnUpdatePayload), so clearing a description/display name still works for every caller without changing the new server contract.

Tests

  • ColumnRepositoryTest (8 cases): empty / whitespace / absent description preserved; removeDescription/removeDisplayName clear; remove flags take precedence; non-blank updates; displayName clear via flag.
  • Verified end-to-end on a 5-level nested table: empty-description PUT no longer drops the existing description; explicit clear and normal updates still work.

Related (customer report + Collate-side prompt fix): open-metadata/openmetadata-collate#4701

Greptile Summary

This PR fixes silent description/displayName data loss on the PUT /api/v1/columns/name/{fqn} endpoint, where blank values were previously treated as "delete" — wiping existing descriptions on sibling/child columns when a partial struct-column update omitted those fields. The server now treats blank as "no change" and requires explicit removeDescription/removeDisplayName flags to clear a field; the UI normalizes user-cleared-blank input into these flags in one central utility before sending to the API.

  • Server (ColumnRepository.java): applyColumnUpdates made package-private static and updated so blank/null description/displayName is a no-op; clearing requires removeDescription / removeDisplayName flags, mirroring the existing removeConstraint pattern. 8 unit tests added.
  • Schema (updateColumn.json / updateColumn.ts): Two new boolean fields removeDescription and removeDisplayName added with documentation that blank values are "no change".
  • UI (ColumnUpdateUtils.ts, tableAPI.ts, dataModelsAPI.ts): normalizeColumnUpdatePayload centralizes the blank-string → remove-flag translation for every API caller; API functions typed to UpdateColumn instead of Partial<Column>. 8 unit tests added.

Confidence Score: 5/5

Safe to merge — the change is a targeted, well-tested preservation of existing data rather than any structural rework.

The server-side fix is narrowly scoped to applyColumnUpdates, is fully covered by 8 dedicated unit tests, and the new blank-is-no-op contract is symmetric across both description and displayName. The UI-side normalizeColumnUpdatePayload correctly translates cleared user input into the explicit remove flags in one place, and its own 8 tests confirm the immutability, passthrough, and blank-conversion paths. No existing behaviours are changed for callers sending non-blank values.

No files require special attention.

Important Files Changed

Filename Overview
openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ColumnRepository.java Core fix: applyColumnUpdates now treats blank description/displayName as no-op and exposes explicit remove flags; made package-private static for unit testability. Logic is symmetric with existing removeConstraint pattern.
openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/ColumnRepositoryTest.java New unit test class covering all 8 edge cases for the blank-preserves and remove-flag-clears contract; test coverage is thorough.
openmetadata-spec/src/main/resources/json/schema/api/data/updateColumn.json Schema extended with removeDescription and removeDisplayName boolean fields including documentation about the new blank-is-no-change contract. Consistent with removeConstraint pattern.
openmetadata-ui/src/main/resources/ui/src/utils/ColumnUpdateUtils.ts New normalizeColumnUpdatePayload centralizes blank-to-remove-flag translation for both description and displayName. Shallow copy is safe since the result is immediately consumed by the caller. Well-tested.
openmetadata-ui/src/main/resources/ui/src/rest/tableAPI.ts API function re-typed to UpdateColumn and normalization applied; correctly delegates blank-to-flag conversion to the central utility.
openmetadata-ui/src/main/resources/ui/src/rest/dataModelsAPI.ts Same pattern as tableAPI.ts: re-typed to UpdateColumn, normalization applied consistently.
openmetadata-ui/src/main/resources/ui/src/generated/api/data/updateColumn.ts Generated TypeScript interface updated to reflect new schema fields and doc comments; appears to be correctly regenerated from the JSON schema.
openmetadata-ui/src/main/resources/ui/src/utils/ColumnUpdateUtils.test.tsx 8 new test cases for normalizeColumnUpdatePayload covering all blank/whitespace/non-blank variants for both fields plus immutability check. Coverage is complete.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant UI as UI Component
    participant Utils as ColumnUpdateUtils.ts
    participant API as tableAPI.ts / dataModelsAPI.ts
    participant Server as ColumnRepository.java
    participant DB as Database

    Note over UI,DB: User clears a column description
    UI->>API: "updateTableColumn(fqn, { description: '' })"
    API->>Utils: "normalizeColumnUpdatePayload({ description: '' })"
    Utils-->>API: "{ removeDescription: true }"
    API->>Server: "PUT /columns/name/{fqn} { removeDescription: true }"
    Server->>Server: "removeDescription=true sets description to null"
    Server->>DB: PATCH via JSON-Patch
    DB-->>Server: saved
    Server-->>API: Column (description: null)
    API-->>UI: Column (description: null)

    Note over UI,DB: User sends partial update (omits description)
    UI->>API: "updateTableColumn(fqn, { displayName: 'Full Name' })"
    API->>Utils: "normalizeColumnUpdatePayload({ displayName: 'Full Name' })"
    Utils-->>API: "{ displayName: 'Full Name' }"
    API->>Server: "PUT /columns/name/{fqn} { displayName: 'Full Name' }"
    Server->>Server: description absent, no change, preserves existing
    Server->>DB: PATCH via JSON-Patch
    DB-->>Server: saved
    Server-->>API: Column (description preserved)
    API-->>UI: Column (description preserved)
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant UI as UI Component
    participant Utils as ColumnUpdateUtils.ts
    participant API as tableAPI.ts / dataModelsAPI.ts
    participant Server as ColumnRepository.java
    participant DB as Database

    Note over UI,DB: User clears a column description
    UI->>API: "updateTableColumn(fqn, { description: '' })"
    API->>Utils: "normalizeColumnUpdatePayload({ description: '' })"
    Utils-->>API: "{ removeDescription: true }"
    API->>Server: "PUT /columns/name/{fqn} { removeDescription: true }"
    Server->>Server: "removeDescription=true sets description to null"
    Server->>DB: PATCH via JSON-Patch
    DB-->>Server: saved
    Server-->>API: Column (description: null)
    API-->>UI: Column (description: null)

    Note over UI,DB: User sends partial update (omits description)
    UI->>API: "updateTableColumn(fqn, { displayName: 'Full Name' })"
    API->>Utils: "normalizeColumnUpdatePayload({ displayName: 'Full Name' })"
    Utils-->>API: "{ displayName: 'Full Name' }"
    API->>Server: "PUT /columns/name/{fqn} { displayName: 'Full Name' }"
    Server->>Server: description absent, no change, preserves existing
    Server->>DB: PATCH via JSON-Patch
    DB-->>Server: saved
    Server-->>API: Column (description preserved)
    API-->>UI: Column (description preserved)

Reviews (7): Last reviewed commit: "test(ui): cover normalizeColumnUpdatePay..." | Re-trigger Greptile

Vishnuujain avatar Jun 24 '26 20:06 Vishnuujain

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • Issue #29487 is missing Shipping → Status.

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

github-actions[bot] avatar Jun 24 '26 20:06 github-actions[bot]

🟡 Playwright Results — all passed (20 flaky)

✅ 4456 passed · ❌ 0 failed · 🟡 20 flaky · ⏭️ 38 skipped

Shard Passed Failed Flaky Skipped
🟡 Shard 1 323 0 2 4
🟡 Shard 2 824 0 5 9
🟡 Shard 3 827 0 2 7
🟡 Shard 4 829 0 2 10
🟡 Shard 5 870 0 4 0
🟡 Shard 6 783 0 5 8
🟡 20 flaky test(s) (passed on retry)
  • Pages/SearchSettings.spec.ts › Preview config reflects reverted n-gram weight after save (shard 1, 1 retry)
  • Flow/SearchRBAC.spec.ts › the browse tree only shows the asset-type categories a user can access (shard 1, 1 retry)
  • Features/BulkEditEntity.spec.ts › Glossary (shard 2, 1 retry)
  • Features/BulkEditOperationBadges.spec.ts › Glossary bulk edit search filters rows and clear restores them (shard 2, 1 retry)
  • Features/BulkImport.spec.ts › Database Schema (shard 2, 1 retry)
  • Features/ContextCenterPermission.spec.ts › user with deleteAll permission can see delete action but not restore action on an archived document, and can delete it (shard 2, 2 retries)
  • Features/Glossary/GlossaryRemoveOperations.spec.ts › should add and remove owner from glossary (shard 2, 1 retry)
  • Features/IncidentManager.spec.ts › Complete Incident lifecycle with table owner (shard 3, 1 retry)
  • Features/Workflows/WorkflowOssRestrictions.spec.ts › add-event-filter-button is enabled in OSS (shard 3, 1 retry)
  • Flow/FrequentlyJoined.spec.ts › should display frequently joined columns (shard 4, 1 retry)
  • Flow/PersonaFlow.spec.ts › Set default persona for team should work properly (shard 4, 1 retry)
  • Pages/Entity.spec.ts › Tier Add, Update and Remove (shard 5, 1 retry)
  • Pages/EntityDataSteward.spec.ts › Tier Add, Update and Remove (shard 5, 1 retry)
  • Pages/ExploreBrowse.spec.ts › service type drill-down disables unrelated roots and query-panel Clear resets it (shard 5, 2 retries)
  • Pages/ExplorePageRightPanel_KnowledgeCenter.spec.ts › Should remove user owner for knowledgeCenter (shard 5, 1 retry)
  • Pages/Glossary.spec.ts › Update glossary display name via rename modal (shard 6, 1 retry)
  • Pages/GlossaryImportExport.spec.ts › Import partial success - some terms pass, some fail (shard 6, 2 retries)
  • Pages/GlossaryImportExport.spec.ts › Glossary CSV import preserves typed relations (shard 6, 1 retry)
  • Pages/Lineage/DataAssetLineage.spec.ts › Column lineage for topic -> dashboard (shard 6, 1 retry)
  • Pages/Lineage/LineageFilters.spec.ts › Verify Impact Analysis service filter selection (shard 6, 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

github-actions[bot] avatar Jun 24 '26 23:06 github-actions[bot]

✅ TypeScript Types Auto-Updated

The generated TypeScript types have been automatically updated based on JSON schema changes in this PR.

github-actions[bot] avatar Jun 25 '26 03:06 github-actions[bot]

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 63%
63.45% (70750/111503) 45.92% (40668/88547) 47.85% (12386/25880)

github-actions[bot] avatar Jun 25 '26 04:06 github-actions[bot]

The Java checkstyle failed.

Please run mvn spotless:apply in the root of your repository and commit the changes to this PR. You can also use pre-commit to automate the Java code formatting.

You can install the pre-commit hooks with make install_test precommit_install.

github-actions[bot] avatar Jun 26 '26 06:06 github-actions[bot]

✅ TypeScript Types Auto-Updated

The generated TypeScript types have been automatically updated based on JSON schema changes in this PR.

github-actions[bot] avatar Jun 26 '26 06:06 github-actions[bot]

Closing — this PR fixes the wrong layer.

Re-investigating the original customer report (Collate Documentation Agent skipping nested-column descriptions, server version 1.12.12) with the actual ingestion log + browser HAR shows:

  1. The agent never calls this endpoint. Its only write is createSuggestion; the column descriptions land as pending suggestions, not direct PUT /columns/name/{fqn} calls. All 24 suggestions in the repro carried non-empty descriptions.
  2. The customer-visible bug is a generation gap — the agent went full-depth on some subtrees but skipped one nested branch entirely. That is fixed in the Collate agent prompt, not here.
  3. The suggestion accept→apply path doesn't go through applyColumnUpdates (the method this PR changed):
    • 1.12.x / 1.13 → TableRepository.applySuggestion (recursive, sets only the matched column; clean since #22348).
    • main (2.0) → SuggestionHandler (JSON-patch).

So this PR changes the global /columns/name PUT contract (blank = no-change + removeDescription/removeDisplayName) and ripples into UI clear-flows, without addressing the reported bug — and it isn't on the code path that produced the wipe I originally repro'd by hand. That hand-crafted {"description":""} PUT reproduced a different bug than the customer's flow.

Closing as wrong-layer / scope creep. The one genuinely open question — nested-column description suggestions on main's SuggestionHandler (object-keyed JSON pointers against the columns array, no nested tests) — is tracked separately.

Vishnuujain avatar Jun 30 '26 13:06 Vishnuujain

Code Review ✅ Approved 3 resolved / 3 findings

Transitions column updates to an explicit-clear contract by introducing removeDescription and removeDisplayName flags, preventing accidental data loss during partial updates. Updated UI payload normalization ensures consistent clearing behavior and comprehensive test coverage.

✅ 3 resolved
✅ Bug: displayName blank-clears behavior silently changed for existing clients

📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ColumnRepository.java:355-361 📄 openmetadata-spec/src/main/resources/json/schema/api/data/updateColumn.json:9-17 This commit changes the contract for displayName on PUT /api/v1/columns/name/{fqn}. Previously a blank/whitespace-only displayName cleared the existing value (old code: setDisplayName(name.trim().isEmpty() ? null : name)); now a blank value is treated as "no change" and clearing requires the new removeDisplayName flag (ColumnRepository.java:355-361). While the description fix is the actual bug being addressed, the displayName change is a separate, breaking contract change for any client (UI, scripts, integrations) that currently sends an empty displayName to clear it — such clients will silently stop clearing display names with no error.

The ReviewExplorer did not find evidence of internal callers relying on blank-to-clear, which reduces risk, but external/UI clients are not covered by that search. Recommend confirming the frontend has been updated to send removeDisplayName: true where it previously sent an empty displayName, and that this contract change is captured in release notes/migration docs.

✅ Bug: Blank displayName/description no longer clears via existing UI flows

📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ColumnRepository.java:355-369 applyColumnUpdates now treats a blank/whitespace displayName or description as "no change" (preserve existing). This fixes the description data-loss bug, but it also silently changes the previously-shipped behavior where a blank value cleared the field. The OpenMetadata UI still relies on the old blank-to-clear contract and was not updated to send the new removeDisplayName / removeDescription flags:

  • SchemaTable.component.tsx handleEditColumnData (lines 562-580) sends displayName: displayName directly. When a user clears the display name, the UI sends displayName: "", which under the new contract is a no-op — so clearing a column display name from the UI no longer works.
  • handleEditColumnChange (lines 453-462) sends description: columnDescription directly. Clearing a column description from the UI now sends description: "", also a no-op.

Note how the same component already adopted the equivalent removeConstraint: true flag for constraints, but the display-name/description clear paths were not migrated. Net effect: the bug fix is correct, but it introduces a user-facing regression — users can no longer clear a column's display name or description through the UI until the UI callers are updated to set the new remove flags when the value is blank.

✅ Quality: New normalizeColumnUpdatePayload lacks direct unit tests

📄 openmetadata-ui/src/main/resources/ui/src/utils/ColumnUpdateUtils.ts:61-75 normalizeColumnUpdatePayload encodes the UI-side half of the new server contract (blank description/displayName => removeDescription/removeDisplayName flag, non-blank => unchanged, absent => untouched). This is the exact logic that prevents the silent data-loss regression this PR fixes, yet the existing ColumnUpdateUtils.test.tsx only covers the in-memory helpers and not this function. The Java ColumnRepositoryTest validates the server side, but there is no UI test asserting the translation. A small behavior-driven test would lock in the four key cases: (1) empty string -> removeDescription: true and description deleted, (2) whitespace-only -> remove flag, (3) non-blank string -> passed through unchanged with no remove flag, (4) absent field -> left untouched (no flag added). Same for displayName.

Options

Display: compact → Showing less information.

Comment with these commands to change:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

gitar-bot avatar Jun 30 '26 13:06 gitar-bot