Check For No Such Element Exception#552
Open
PujaDeshmukh17 wants to merge 3 commits into
Open
Conversation
PujaDeshmukh17
had a problem deploying
to
pr-analysis
July 22, 2026 08:50 — with
GitHub Actions
Failure
PujaDeshmukh17
temporarily deployed
to
pr-analysis
July 22, 2026 09:04 — with
GitHub Actions
Inactive
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
When users discarded a draft in applications using the SDM plugin, they encountered a NoSuchElementException crash. The error originated in SDMServiceGenericHandler.java in the discard-draft revert logic, where two Optional.get() calls were made without first checking whether the Optional was present:
// 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.
Single Tenant Integration Test: https://github.com/cap-java/sdm/actions/runs/29914082169/job/88903691196
Type of change
Please delete options that are not relevant.
Checklist before requesting a review
Upload Screenshots/lists of the scenarios tested