Fix METADATA_ALREADY_EXISTS error in CrossKalturaDistributionEngine metadata sync - #2
Open
devin-ai-integration[bot] wants to merge 2 commits into
Conversation
…raDistributionEngine Before adding metadata to the target entry, list existing metadata to detect manually created metadata objects. If metadata for the same profile already exists on the target, update it instead of attempting to add, which would fail with METADATA_ALREADY_EXISTS. Co-Authored-By: bryna.weissman@kaltura.com <bryna.weissman@kaltura.com>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
…upfront Only list metadata for the specific metadataProfileId being added, rather than fetching all metadata on the target entry. This is more targeted and avoids unnecessary data transfer when most metadata objects are already tracked in the distributed map. Co-Authored-By: bryna.weissman@kaltura.com <bryna.weissman@kaltura.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a bug in
CrossKalturaDistributionEngine::sync()where syncing metadata objects to a target entry fails withMETADATA_ALREADY_EXISTSif someone manually added metadata to the target entry outside the distribution flow.Problem: When metadata is not in the
distributedMap(i.e., not previously distributed), the code always tries toaddnew metadata. If matching metadata (samemetadataProfileId) was manually created on the target entry, the add call fails because metadata is unique per(objectId, metadataProfileId, objectType).Fix: Before adding each metadata object, do a targeted
metadata->listAction()filtered byobjectIdEqual,metadataObjectTypeEqual, andmetadataProfileIdEqualto check if metadata for that specific profile already exists on the target. If it does, inject the existing target metadata ID into the distributed map sosyncTargetEntryObjectstreats it as an update instead of an add.This per-profile approach only makes the list call for metadata objects not already in the distributed map, and filters by the exact profile being added — avoiding unnecessary data transfer.
Review & Testing Checklist for Human
METADATA_ALREADY_EXISTSNotes
distributedMapis rebuilt from scratch after sync viagetDistributedMap(), so injecting synthetic entries before the sync has no lasting side effectsDISTRIBUTED_INFO_SOURCE_UPDATED_ATis not set in the injected entry, the update path insyncTargetEntryObjectscorrectly falls through to perform the update (the null check ensures this)Link to Devin session: https://app.devin.ai/sessions/85d0938a18374be38b10c6f88edca4e5
Requested by: @bw-kaltura