Repository navigation
Fixes #33324: let a force-sync refresh connector-supplied custom properties [Backport #35622 - 2.0] - #35707
Conversation
…erties (#35622) * Fixes #33324: let a force-sync refresh connector-supplied custom properties Connector-supplied `extension` values landed only on an entity's first write. EntityRepository.updateExtension reverts any bot PUT to the stored extension, and ingestion authenticates as ingestion-bot over the bulk PUT path, so a changed custom property never propagated and a newly added one never appeared. Deleting and re-ingesting the entity was the only workaround. The guard itself is right - it stops a scheduled re-sync from clobbering custom properties a user curated in the UI. What it lacked was the opt-out every comparable field already has. overrideMetadata is set on the updater and read in updateDescription, updateDisplayName, updateTags and updateCertification, but updateExtension never consulted it: 0 of the 25 references in the class were in that method. It now follows the same shape as its four siblings - the bot guard applies unless overrideMetadata is set and the incoming extension is non-empty. Emptiness is tested through the nullOrEmpty(JsonNode) overload rather than nullOrEmpty(Object), which stringifies an empty map to "{}" and would call it non-empty. A connector that is not collecting custom properties sends no extension, and that absence must not blank the stored ones. A force-sync merges rather than replaces. The diff below the guard treats a stored key the request omits as a deletion, so a plain replace would drop custom properties a user set in the UI the moment any connector force-synced one property of its own - reintroducing the exact loss the guard prevents. Tags can afford replace semantics because TagLabel carries LabelType and the update path filters on it; a custom property carries no provenance at all, and ingestion only ever sends the properties its own source produces. So the keys the connector sends win and the rest are left alone. The cost of that choice: a property removed at the source lingers until someone deletes it. Removing it automatically needs per-key provenance to tell a connector-owned property from a curated one, which is the larger design #33324 raises as the alternative and is not attempted here. Scope: updateExtension is on the generic EntityUpdater, so this reaches every entity type and every writer of an extension - Athena and Glue via the table hook, dbt on Metric, SAS on Table. Default behaviour is unchanged, because overrideMetadata defaults to false; nothing moves unless an operator has explicitly turned on Override Metadata for that pipeline. Tests: EntityRepositoryExtensionTest, 7 cases driving updateExtension through the updater. Three fail without the change - a bot PUT under overrideMetadata leaving a value stale, dropping a newly added property, and losing a curated property the connector does not send. The other four pin the behaviour that must not move: a bot PUT without overrideMetadata keeps the stored extension, a null or empty incoming extension never blanks it, and a human PUT still applies. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * Record the force-sync merge decision, cover the non-object path A force-sync merges the incoming extension over the stored one rather than replacing it. Tags do replace under the same flag and can afford to, because TagLabel carries LabelType; a custom property has no provenance at all, so the merge reads like an inconsistency someone could tidy away. The squash-merge drops the PR description, so the rule goes in the tree and is cited from the Javadoc. Also tests mergedOverStoredExtension's non-object path, taking it to 7/7 lines. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * fix(test): updateExtension behaviour --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]> (cherry picked from commit 38b3094)
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
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 |
Code Review ✅ Approved🔴 High risk · Allowing force-sync to merge connector-supplied properties into stored extensions could overwrite curated values when source data is incorrect. Backports the fix that lets force-sync refresh connector-supplied custom properties by merging incoming VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
| if (!stored.isObject() || !incoming.isObject()) { | ||
| return incomingExtension; | ||
| } | ||
| ObjectNode merged = stored.deepCopy(); | ||
| merged.setAll((ObjectNode) incoming); | ||
| return JsonUtils.treeToValue(merged, Object.class); |
There was a problem hiding this comment.
mergedOverStoredExtension has an early return and a second return at the end. The Java guide requires one return statement per method, placed at the end. Use a result variable and an if/else here. This repository requirement must be satisfied before merging.
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
This backports #35622 and keeps the same code as main, so 2.0 stays in sync and later backports apply cleanly. A single-return refactor would need to land on main first.
There was a problem hiding this comment.
That’s fair. Since this is an intentional backport preserving the main-branch implementation for parity and clean future cherry-picks, I won’t require a 2.0-only single-return refactor. This style adjustment can be made on main first, then backported if desired.
| private Object mergedOverStoredExtension(Object storedExtension, Object incomingExtension) { | ||
| JsonNode stored = JsonUtils.valueToTree(storedExtension); | ||
| JsonNode incoming = JsonUtils.valueToTree(incomingExtension); |
There was a problem hiding this comment.
The new helpers declare unchanged parameters and local variables without final. The Java guide requires final on values that do not change. Apply it here and to the unchanged declarations in the new test. This repository requirement must be satisfied before merging.
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
Same code as main's #35622. The backport intentionally matches main, so adding final would need to land on main first.
There was a problem hiding this comment.
Understood. Since this backport intentionally matches #35622, adding final only here would create an unnecessary divergence from main. I’ll treat this finding as not applicable to the backport; consistency with main takes precedence.
| Pipeline original = pipelineWithExtension(BOT_NAME, extension("owner_team", "curated")); | ||
| Pipeline updated = pipelineWithExtension(BOT_NAME, extension("owner_team", "from-source")); |
There was a problem hiding this comment.
The new test repeats property names and other fixture strings. The Java guide requires a named constant when a string appears more than once. Extract constants for values such as owner_team and curated_note, and reuse Entity.INGESTION_BOT_NAME rather than defining the bot name again. This repository requirement must be satisfied before merging.
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
This test is the same as on main (#35622), and the backport keeps it that way. Extracting constants would need to land on main first.
There was a problem hiding this comment.
That’s fair. Since this is an intentional backport of the accepted main change, extracting constants here would create an unnecessary divergence and require a separate change on main first. I’m withdrawing this finding; no change is needed for this PR.
| .withName(Entity.PIPELINE) | ||
| .withCategory(Category.Entity) | ||
| .withCustomProperties( | ||
| java.util.Arrays.stream(propertyNames) |
There was a problem hiding this comment.
Helper skips the required import
java.util.Arrays.stream uses a fully qualified class name in the method body. The Java guide requires imports instead. Import Arrays and use Arrays.stream(propertyNames). This repository requirement must be satisfied before merging.
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
Same code as main's #35622, kept as is so the backport matches main. Importing Arrays would need to land on main first.
There was a problem hiding this comment.
That’s fair. Since this backport intentionally preserves the main implementation verbatim, and the fully qualified java.util.Arrays.stream is functionally correct, I’ll withdraw this finding rather than require a backport-only style change. The import can be cleaned up on the main change if the project wants that convention applied consistently.
| private static void invokeUpdateExtensionOnRealPath( | ||
| EntityRepository<Pipeline>.EntityUpdater updater) throws Exception { | ||
| Method method = | ||
| EntityRepository.EntityUpdater.class.getDeclaredMethod("updateExtension", boolean.class); | ||
| method.setAccessible(true); | ||
| method.invoke(updater, false); |
There was a problem hiding this comment.
invokeUpdateExtensionOnRealPath duplicates the reflection code in invokeUpdateExtension; only the boolean argument differs. The Java guide requires copied blocks to become a shared, parameterized helper. Pass consolidatingChanges into one helper instead. This repository requirement must be satisfied before merging.
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
Same as main's #35622, and we're keeping the backport identical to main. Merging the two helpers would need to land on main first.
There was a problem hiding this comment.
| registerBotUser(); | ||
|
|
||
| Pipeline original = pipelineWithExtension(BOT_NAME, extension("owner_team", "curated")); | ||
| Pipeline updated = pipelineWithExtension(BOT_NAME, new LinkedHashMap<String, Object>()); |
There was a problem hiding this comment.
Constructor repeats type arguments
new LinkedHashMap<String, Object>() repeats the type arguments. The Java guide requires the diamond operator. Use new LinkedHashMap<>(). This repository requirement must be satisfied before merging.
| Pipeline updated = pipelineWithExtension(BOT_NAME, new LinkedHashMap<String, Object>()); | |
| Pipeline updated = pipelineWithExtension(BOT_NAME, new LinkedHashMap<>()); |
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
Kept as in main's #35622 so the backport matches main. The diamond change would need to land on main first.
There was a problem hiding this comment.
That’s a valid backport constraint. Keeping the fixture identical to main is reasonable here, and changing it independently would reduce parity with #35622. I’m withdrawing this finding for the backport.
| private static void seedStringCustomProperties(String... propertyNames) { | ||
| TypeRegistry.instance() | ||
| .addType(new Type().withName("string").withSchema("{\"type\":\"string\"}")); | ||
| TypeRegistry.instance() | ||
| .addType( | ||
| new Type() | ||
| .withName(Entity.PIPELINE) | ||
| .withCategory(Category.Entity) | ||
| .withCustomProperties( |
There was a problem hiding this comment.
Test leaves shared types behind
seedStringCustomProperties changes the shared TypeRegistry, but tearDown only clears Entity. The registered string and pipeline types and their custom properties remain after this test. Restore or remove these registrations during cleanup so later tests do not inherit this fixture.
There was a problem hiding this comment.
Same test as main's #35622, kept identical here. The TypeRegistry cleanup applies to main too, so it should be fixed there first and then backported.
There was a problem hiding this comment.
That’s fair. Since this fixture is intentionally identical to the main change and the TypeRegistry cleanup issue exists there as well, the correct fix is to update #35622 first and then backport that cleanup here. I’ll treat this as an upstream follow-up rather than requiring a 2.0-only deviation.
Describe your changes:
Backport of #35622 (38b3094) to
2.0. Fixes #33324 on 2.0.Connector-supplied custom properties (
extension) were written only on an entity's first ingestion.EntityRepository.updateExtensionreverts every bot PUT to the stored extension, and ingestion writes asingestion-botover the bulk PUT path. So a changed source value never reached the entity, and a newly added one never appeared.updateExtensionnow honoursoverrideMetadata, asupdateDescription,updateDisplayName,updateTagsandupdateCertificationalready do. When it is set and the incoming extension is non-empty, the incoming properties are merged over the stored ones. Keys the connector sends win, and keys it omits, such as properties curated in the UI, are kept.overrideMetadatadefaults tofalse, so nothing changes until an operator turns on Override Metadata for the pipeline. For why it merges instead of replacing, see #35622 and the ADR it adds.Differences from the main commit
EntityRepository.java: applied cleanly. The change is identical to main's (samegit patch-id).EntityRepositoryExtensionTest.java: one import differs. On main,TagUsageDAOlives inClassificationTagDAOs, which 2.0 doesn't have; on 2.0 it is nested inCollectionDAO. The test importsorg.openmetadata.service.jdbi3.CollectionDAO.TagUsageDAOinstead, and the rest of the file is unchanged.docs/decisions/2026-10-16-a-force-sync-merges-connector-supplied-custom-properties.mdis kept, because the new Javadoc cites it.Everything the fix relies on is already on 2.0:
EntityUpdater.overrideMetadataand its setter, thenullOrEmpty(JsonNode)overload, andJsonUtils.valueToTree/treeToValue. 2.0'supdateExtensionmatches main's except for its last step, which persists the extension withremoveExtension+storeExtensioninstead of main'sreplaceExtension. That step runs after the merge and stores whatever the merge produced, so it doesn't change what this fix does.Tests
No tests were run locally for this backport.
EntityRepositoryExtensionTest(9 cases) and the backend suites run in this PR's CI.Checked locally:
mvn spotless:check -pl openmetadata-servicepasses.Type of change:
🤖 Generated with Claude Code
The merge behavior appears sound, but the explicit Java requirements must be satisfied before merging.
Findings
Summary
Lets bot PUTs refresh custom properties when
overrideMetadatais enabled.Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Bot PUT] --> B{Override enabled and extension non-empty?} B -->|No| C[Keep stored extension] B -->|Yes| D[Merge incoming keys over stored keys] D --> E[Compare properties] E --> F[Validate changed properties] F --> G[Store extension]Reviews (1) · Last reviewed commit: "Fixes #33324: let a force-sync refresh c..." · Reviewed by Greptile