fix(attachments): prevent orphaned DMS files by moving DMS operations to on phase (opt-in) - #303
Open
akgarg06 wants to merge 5 commits into
Open
fix(attachments): prevent orphaned DMS files by moving DMS operations to on phase (opt-in)#303akgarg06 wants to merge 5 commits into
on phase (opt-in)#303akgarg06 wants to merge 5 commits into
Conversation
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.
Describe your changes
Problem
DMS operations (upload, rename, delete, link-revert) ran in CAP
beforehandlers.Since before-handlers execute concurrently and the error gate is checked only after
they all complete, a validation reject (or any rollback) could abort the CAP
transaction after the DMS call already executed — leaving an orphaned file in DMS
with no DB record.
srv.prependdoes not fix this (ordering ≠ prevention).Fix
Move all DMS-mutating attachment handlers from
beforeto theonphase(prepended, with
next()chaining). CAP only entersonif nobeforeerrorsoccurred, so a validation reject now prevents the DMS operation entirely.
Handlers moved: draft upload, non-draft create/upload, non-draft update/rename,
draft rename (SAVE), non-draft rename, draft discard, draft-attachment delete.
Prep/collect/read handlers stay in
before; the DMS delete stays inafter.Opt-in flag (default OFF — no behavior change unless enabled)
cds.requires.sdm.settings.uploadInOnPhase: true, orSDM_UPLOAD_IN_ON_PHASE=trueType of change
Please delete options that are not relevant.
Checklist before requesting a review
Upload Screenshots/lists of the scenarios tested
Multi tenant Integration test : https://github.com/cap-js/sdm/actions/runs/31776642709
Single Tenant Integration test : https://github.com/cap-js/sdm/actions/runs/31776340192