Skip to content

Duplicate key error and 3.13.5 - #523

Open
eric-pSAP wants to merge 7 commits into
mainfrom
v3.13.5
Open

Duplicate key error and 3.13.5#523
eric-pSAP wants to merge 7 commits into
mainfrom
v3.13.5

Conversation

@eric-pSAP

@eric-pSAP eric-pSAP commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

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 after attachment.put() instead of calling next(), while preserving next() 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 from 3.13.4 to 3.13.5 and constrained @sap/cds peer dependency to >=8 <10.
  • CHANGELOG.md: Added release notes for version 3.13.5 documenting the duplicate-key fix.
  • 🔄 Regenerate and Update Summary
PR Bot Information

Version: 1.31.27

  • File Content Strategy: Full file content
  • Event Trigger: pull_request.opened
  • Summary Prompt: Default Prompt
  • Correlation ID: 394b3eb0-ac5b-11f1-8421-ebfe67973e81
  • Output Template: Default Template
  • LLM: gpt-5.5

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.
@eric-pSAP
eric-pSAP requested a review from a team as a code owner September 9, 2026 14:32

@hyperspace-pr-bot hyperspace-pr-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
KoblerS previously approved these changes Sep 10, 2026
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.

2 participants