Skip to content

Check For No Such Element Exception#552

Open
PujaDeshmukh17 wants to merge 3 commits into
Release_v1.9.2from
RBSDMS-NoElementError-feature
Open

Check For No Such Element Exception#552
PujaDeshmukh17 wants to merge 3 commits into
Release_v1.9.2from
RBSDMS-NoElementError-feature

Conversation

@PujaDeshmukh17

@PujaDeshmukh17 PujaDeshmukh17 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

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.

  • Bug fix (non-breaking change which fixes an issue)

Checklist before requesting a review

  • I follow Java Development Guidelines for SAP
  • I have tested the functionality on my cloud environment.
  • I have provided sufficient automated/ unit tests for the code.
  • I have increased or maintained the test coverage.
  • I have ran integration tests on my cloud environment.
  • I have validated blackduck portal for any vulnerability after my commit.

Upload Screenshots/lists of the scenarios tested

  • I have Uploaded Screenshots or added lists of the scenarios tested in description

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.

1 participant