Skip to content

Fix/bypass draft does not cause attachment deletion#417

Merged
KoblerS merged 9 commits intomainfrom
fix/bypass-draft-does-not-cause-attachment-deletion
Apr 2, 2026
Merged

Fix/bypass draft does not cause attachment deletion#417
KoblerS merged 9 commits intomainfrom
fix/bypass-draft-does-not-cause-attachment-deletion

Conversation

@schiwekM
Copy link
Copy Markdown
Contributor

@schiwekM schiwekM commented Apr 2, 2026

When fire.bypass_draft was enabled no draft, in the UPDATE handler detecting draft changes, was returned causing the deletion logic to delete all active attachments.

@schiwekM schiwekM requested a review from a team as a code owner April 2, 2026 14:04
@schiwekM schiwekM requested a review from KoblerS April 2, 2026 14:04
@hyperspace-insights
Copy link
Copy Markdown
Contributor

Summary

The following content is AI-generated and provides a summary of the pull request:


Fix: Bypass Draft Mode Causing Unintended Attachment Deletion

Bug Fix

🐛 Fixed a bug where enabling cds.env.fiori.bypass_draft caused all active attachments to be wrongfully deleted when updating a parent entity. In bypass draft mode, no draft record exists, so the UPDATE handler's deletion logic was incorrectly interpreting the absence of a draft as a signal to delete all active attachments.

Changes

  • srv/basic.js: Changed the draft variable declaration from const to let and added an early return guard — if no draft is found (indicating bypass draft mode is active), the attachment deletion handler is skipped entirely with a debug log message.
  • tests/integration/attachments.test.js: Added a new integration test "Updating parent should not cause attachment deletes" that verifies attachments remain intact after a direct PATCH to an active entity when bypass draft is enabled. The test also confirms file content is still accessible after the update.
  • package.json: Added fiori.bypass_draft: true to the CDS configuration block to enable bypass draft mode for testing purposes.
  • CHANGELOG.md: Added a fix entry for version 3.11.0 documenting the bug fix.

  • 🔄 Regenerate and Update Summary
  • ✏️ Insert as PR Description (deletes this comment)
  • 🗑️ Delete comment
PR Bot Information

Version: 1.20.0 | 📖 Documentation | 🚨 Create Incident | 💬 Feedback

  • Event Trigger: pull_request.opened
  • Output Template: Default Template
  • LLM: anthropic--claude-4.6-sonnet
  • Summary Prompt: Default Prompt
  • File Content Strategy: Full file content
  • Correlation ID: dacba0f0-2e9c-11f1-92ca-ac2c21ce9708

💌 Have ideas or want to contribute? Create an issue and share your thoughts with us!
📑 Check out the documentation for more information.
📬 Subscribe to the Hyperspace PR Bot DL to get the latest announcements and pilot features!

Made with ❤️ by Hyperspace.

Copy link
Copy Markdown
Contributor

@hyperspace-insights hyperspace-insights bot left a comment

Choose a reason for hiding this comment

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

The fix in srv/basic.js is correct and well-placed, but the test validating it has significant issues: waitForDeletion is always called with the record's UUID instead of its storage URL, meaning the negative assertion trivially passes regardless of whether a deletion actually fired — so the bug could silently regress. Additionally, setting fiori.bypass_draft: true globally in package.json puts the entire test suite in bypass-draft mode, which may mask regressions in standard draft-flow tests.

PR Bot Information

Version: 1.20.0 | 📖 Documentation | 🚨 Create Incident | 💬 Feedback

  • File Content Strategy: Full file content
  • Event Trigger: pull_request.opened
  • LLM: anthropic--claude-4.6-sonnet
  • Correlation ID: dacba0f0-2e9c-11f1-92ca-ac2c21ce9708

Comment thread tests/integration/attachments.test.js Outdated
Comment thread tests/integration/attachments.test.js Outdated
Comment thread tests/integration/attachments.test.js
Comment thread package.json
Comment thread srv/basic.js Outdated
@schiwekM schiwekM requested a review from KoblerS April 2, 2026 14:42
@schiwekM schiwekM enabled auto-merge (squash) April 2, 2026 14:58
@KoblerS KoblerS merged commit 477f1b3 into main Apr 2, 2026
29 of 38 checks passed
@KoblerS KoblerS deleted the fix/bypass-draft-does-not-cause-attachment-deletion branch April 2, 2026 16:25
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.

3 participants