Skip to content

Fix: Invalid CQN error during draftActivate on deeply nested entities - #563

Open
PujaDeshmukh17 wants to merge 2 commits into
Release_v1.9.3from
RBSDMS-uploadStatusNocqnFix-feature
Open

Fix: Invalid CQN error during draftActivate on deeply nested entities#563
PujaDeshmukh17 wants to merge 2 commits into
Release_v1.9.3from
RBSDMS-uploadStatusNocqnFix-feature

Conversation

@PujaDeshmukh17

@PujaDeshmukh17 PujaDeshmukh17 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Problem: During draftActivate on entities with deeply nested compositions (5+ levels deep or many compositions), the following error was thrown:

Invalid CQN: Element 'SDM_READONLY_CONTEXT.uploadStatus' does not exist

The internal SDM_READONLY_CONTEXT wrapper key — used to preserve uploadStatus across handler phases — was being removed using plain Map.values() traversal. This traversal cannot reach all composition data in deeply nested CDS structures, leaving stale entries that caused CQN validation failures.

Integration Tests:

  1. Single tenant: https://github.com/cap-java/sdm/actions/runs/31245037895
  2. Multi tenant: https://github.com/cap-java/sdm/actions/runs/31250382719/job/93085724169

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

.count();
if (keyFieldCount > 1) {
logger.warn(
"populateUploadableFlags Path1: entity={} has {} key fields; only '{}' is used for parentId lookup",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For entities with a compound primary key, getAttachmentsForUPID is queried using only the first key field. This over-counts attachments (matches all rows sharing the partial key), producing a wrong isUploadable = false for rows that should be uploadable. All key components must be included in the query predicate.


String cacheKey = facet.facetName + "|" + parentId + "|" + rowIsDraft;
boolean isUploadable =
uploadableCache.computeIfAbsent(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

populateUploadableFlags is an @after LATE handler on all entity reads — including list pages. On a Books list with 20 rows and 2 facets (attachments, references) this fires 40 extra DB queries per page load. Fiori only consumes isUploadable on object page $expand=up_, never on the list page. Add an early-exit guard to skip collection reads (e.g. check if the CQN has a key predicate, or data.size() > 1).

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.

2 participants