Fix: NoSuchElementException on Discard Draft#551
Open
PujaDeshmukh17 wants to merge 3 commits into
Open
Conversation
PujaDeshmukh17
had a problem deploying
to
pr-analysis
July 22, 2026 08:26 — with
GitHub Actions
Failure
PujaDeshmukh17
had a problem deploying
to
pr-analysis
July 22, 2026 08:26 — with
GitHub Actions
Failure
PujaDeshmukh17
temporarily deployed
to
pr-analysis
July 23, 2026 10:11 — with
GitHub Actions
Inactive
PujaDeshmukh17
temporarily deployed
to
pr-analysis
July 23, 2026 10:11 — with
GitHub Actions
Inactive
PujaDeshmukh17
had a problem deploying
to
pr-analysis
July 24, 2026 05:29 — with
GitHub Actions
Failure
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
// Before fix — throws NoSuchElementException if entity not found in model
CdsEntity draftEntity = model.findEntity(draftEntityName).get();
CdsEntity activeEntity = model.findEntity(attachmentCompositionDefinition).get();
This happened in scenarios where the attachment composition entity (or its _drafts counterpart) was not registered in the CDS model at the time of the discard — for example in sourcing applications where the entity definition is not always available in the model. An unchecked .get() on an empty Optional throws NoSuchElementException, causing the entire discard operation to fail.
There was another issue which was observed , that SDM was been called on discard draft button even when there were no links present. This PR will also add a validation check for this.
By adding downloadSelectedAttachments to attachments.cds file we have made this feature as mandatory for all customers, so the ones who do not define leading app changes for this will face compilation issue. This PR will also fix this issue and make downloadSelectedAttachment feature as optional.
Type of change
Please delete options that are not relevant.
Checklist before requesting a review
Upload Screenshots/lists of the scenarios tested