Conversation
For composition-based attachments, attachment.put() already UPSERTs the metadata row to the database. Calling next() afterward caused a second INSERT for the same (up__ID, ID) key, resulting in a duplicate-key error on HANA. Restore the pre-3.13.x short-circuit for isAttachmentsEntity while keeping next() for the inline-attachment path added in #376.
Contributor
There was a problem hiding this comment.
I found a potential correctness issue around mixed bulk INSERTs, but the inline comment could not be posted before the tool limit was reached. Please double-check the new INSERT handler behavior for batches that contain both attachment entries with content and metadata-only entries, as skipping next() for the whole batch may leave metadata-only rows unpersisted.
PR Bot Information
Version: 1.31.27
- File Content Strategy: Full file content
- Event Trigger:
pull_request.opened - LLM:
gpt-5.5 - Correlation ID:
394b3eb0-ac5b-11f1-8421-ebfe67973e81
KoblerS
previously approved these changes
Sep 10, 2026
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.
Fix Duplicate Key Error for Programmatic Attachment Imports
Bug Fix
🐛 Fixed a duplicate-key error on HANA when programmatically inserting composition attachments with file content. The DB insert interception now avoids calling the default insert flow when
attachment.put()has already persisted attachment metadata, preventing duplicate records for the same attachment key.Changes
lib/plugin.js: Updated DB INSERT handling for attachment entities to return processed attachment entries directly afterattachment.put()instead of callingnext(), while preservingnext()for inline attachments that still need parent metadata persistence.tests/integration/attachments-non-draft.test.js: Added a regression test covering programmatic INSERT with attachment content in object-store mode, ensuring only one attachment row is persisted without constraint violations.package.json: Bumped package version from3.13.4to3.13.5and constrained@sap/cdspeer dependency to>=8 <10.CHANGELOG.md: Added release notes for version3.13.5documenting the duplicate-key fix.PR Bot Information
Version:
1.31.27pull_request.opened394b3eb0-ac5b-11f1-8421-ebfe67973e81gpt-5.5