Skip to content

Fixes #39129: prune no-snapshot update baseline to stop spurious JSON Patch removes - #39164

Merged
harshach merged 1 commit into
mainfrom
detail/bug-fix/fixes-39129-prune-no-snapshot-update-baseline-to-s-1dd4eb
Nov 28, 2026
Merged

harshach merged 1 commit into
mainfrom
detail/bug-fix/fixes-39129-prune-no-snapshot-update-baseline-to-s-1dd4eb

Conversation

@detail-app

@detail-app detail-app Bot commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Detail bug report: View on Detail

Fixes #39129

Describe your changes:

I worked on the fluent Java SDK's detached-entity update path because a partial-entity update done without a prior get() (no stored snapshot) emitted remove ops for server-populated fields the caller never touched, causing HTTP 500 (for Spreadsheet) or silent clearing of curated metadata (e.g. displayName).

Bug: EntityServiceBase.update() is the base of every generated SDK entity service. When no in-memory snapshot exists, it re-fetches the server's default GET projection and diffs it directly against the submitted (often sparse) POJO. Because that baseline is not pruned to the submitted fields, JsonDiff turns every server-populated field absent from the submission into a remove op:

  • remove /service → NullPointerException inside SpreadsheetRepository.prepare → HTTP 500 for every sparse Spreadsheet update.
  • remove /displayName → silently clears the field on entities where the PATCH survives.

The legacy sibling BaseResource already prunes the baseline (pruneFieldsNotPresentInUpdated), with a test asserting no remove ops for unspecified fields — but no generated service extends it, so EntityServiceBase (used by all fluent facades like Spreadsheets/Tables) lacked the same guard.

Fix: In the no-snapshot branch of EntityServiceBase.update(), call a new pruneFieldsNotPresentInUpdated(originalNode, updatedNode) right after fetchUpdateBaseline(...) to drop baseline fields absent from the submission before diffing. The snapshot branch is unchanged, so the documented "field cleared after a fetch emits a remove op" behavior keeps working. This mirrors the protection already in BaseResource.

Type of change:

  • Bug fix

High-level design:

N/A — small change. A single recursive baseline-pruner added to EntityServiceBase.update()'s no-snapshot fallback, mirroring the existing BaseResource#pruneFieldsNotPresentInUpdated. The snapshot path is untouched.

Tests:

Use cases covered

  • Detached partial update (no prior get()) changes only the submitted fields and emits no remove ops for unspecified server fields (/service, /displayName, /fullyQualifiedName, /updatedAt, /updatedBy, /serviceType).
  • Detached update that does submit a field (e.g. displayName) still diffs and sends that change.
  • Fetch-then-mutate still emits remove for explicitly cleared fields (snapshot path preserved).
  • Fetch-then-mutate of a full server POJO produces no spurious removes.
  • End-to-end: a detached sparse Spreadsheet update no longer 500s and preserves service/displayName; fetch-then-clear of tags still clears them server-side.

Unit tests

  • I added unit tests for the new/changed logic.
  • Files added/updated:
    • openmetadata-sdk/src/test/java/org/openmetadata/sdk/services/UpdatePruneBaselineTest.java (new) — 6 Mockito-based cases against the real SpreadsheetService/EntityServiceBase with a realistic default-GET fixture.
  • Verified: the new suite (6/6), plus EntityServiceBaseTest (12/12, incl. relatedTerms reference-field re-fetch), BaseResourceTest (2/2), and FluentAddTagPatchRegressionTest (18/18, the tag-baseline machinery) all pass; the full openmetadata-sdk suite (412 tests) is green. Spotless and test-compile are clean. RED/GREEN confirmed: disabling the prune makes 4 of the 6 new tests fail with exactly the reported spurious remove ops (/fullyQualifiedName, /displayName, /service, /serviceType, /updatedAt, /updatedBy).

Backend integration tests

  • I added integration tests in openmetadata-integration-tests/ for the changed update behavior.
  • Files added/updated:
    • openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/SpreadsheetDetachedUpdateIT.java (new) — 3 end-to-end cases: detached partial update preserves server-populated fields (no 500), explicit displayName change still applies, fetch-then-clear of tags still clears them.
  • These run in the merge queue (PR CI runs only Java unit tests). The impact-map planner (make java_affected) confirms SpreadsheetDetachedUpdateIT and FluentAddTagPatchIT are selected for the parallel lane.
  • I could not run these ITs locally: the openmetadata-integration-tests module requires the openmetadata-service test-jar, and openmetadata-service does not compile in this sandbox — a pre-existing shaded-dependency resolution failure where the elasticsearch-deps jar is present, on the classpath, and contains the relocated es.co.elastic.* classes (direct javac against it resolves the imports), yet the Maven compiler reports package es.co.elastic.clients.elasticsearch._types does not exist. This blocker is environmental and unrelated to the change (which touches only openmetadata-sdk). The mock-based equivalents of the tag-clear and field-preservation paths passed in the unit suite, but the server-side NPE / display-name-clearing contract relies on the merge-queue ITs.

Ingestion integration tests

  • Not applicable (no ingestion changes).

Playwright (UI) tests

  • Not applicable (no UI changes).

Manual testing performed

Not performed — backend-only SDK change; end-to-end verification relies on the ITs above.

UI screen recording:

Not applicable — backend-only Java SDK change, no UI impact.

Checklist:

  • I have read CONTRIBUTING.md (the pre-review gate) and the contributor docs.
  • 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 JSON Schema changes: I updated the migration scripts or explained why it is not needed. — N/A (no schema changes)
  • For a UI feature or feature task: … — N/A (backend-only)
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.
  • Self-review: I reviewed the final diff against REVIEW.md and fixed every 🔴 finding.
  • Decision check: no decision record needed — the fix mirrors an existing pattern (BaseResource) and introduces no new schema field, REST path, default, or cross-component contract.
  • I have added a test that covers the exact scenario we are fixing.

Automatic Fixes PRs can be configured here.

@detail-app
detail-app Bot requested a review from harshach November 28, 2026 03:15
@harshach
harshach merged commit 23ab9df into main Nov 28, 2026
35 checks passed
@harshach
harshach deleted the detail/bug-fix/fixes-39129-prune-no-snapshot-update-baseline-to-s-1dd4eb branch November 28, 2026 19:24
mohityadav766 added a commit that referenced this pull request Dec 2, 2026
…schema, stale and slow ITs (#39394)

* fix(sdk): remove fields cleared on a server-returned entity in update()

#39164 pruned the no-snapshot baseline to the fields the caller sent, so a field
nulled on an entity returned by create() or update() was never removed. Prune only
hand-built partial entities, which carry no version or updatedAt.

* test(ontology): create bot_entity in OntologyEntityDAOIT's scratch schema

Approval rules read bot_entity since #38797. Without it the gate refused every
write with "Approval rules are unavailable".

* test(context-memory): align ContextMemoryAnchorIT with memory-only search

#38011 lets a memory-only search return anchored memories a reader may read, but
left one assertion on the old rule. The "all" assertions counted fuzzy-matched
tables and queried the question, which "all" does not search; count memories only
and carry the query in the display name.

* fix(glossary): retry the pending-label drop of a bulk asset removal on deadlock

The chunked DELETE on tag_usage commits on its own and is idempotent, so
DeadlockRetry can rerun it.

* test: tolerate slow runners in OntologyGovernanceIT and ConceptContextIT

Retry a SPARQL request the single worker turns away with 429, and give the
approval workflow the 5 minutes MetricResourceIT already allows.

* test(informix): drop the clear() of per-source stored procedure state

PerSourceState is owned by each source instance, so a second run starts empty
and the object has no clear().

* chore(airflow-apis): refresh uv.lock for the ingestion mcp extra

* test: honour the SPARQL Retry-After and explain the workflow wait

The bounded worker answers saturation with 429 and Retry-After by design, so the
client waits as told. The approval workflow starts only when the serial
WorkflowEventConsumer reaches the create event, which lags under parallel load.

* test: poll the SPARQL retry with Awaitility; guard untouched fields in update()

Replace the sleep loop with Awaitility at the server's Retry-After interval.
Add a test that a server-returned entity with one changed field emits no
remove ops.
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] Java SDK detached/partial entity updates generate unintended JSON Patch removes (Spreadsheet update 500s or clears fields)

1 participant