Fix: Invalid CQN error during draftActivate on deeply nested entities - #563
Fix: Invalid CQN error during draftActivate on deeply nested entities#563PujaDeshmukh17 wants to merge 2 commits into
Conversation
| .count(); | ||
| if (keyFieldCount > 1) { | ||
| logger.warn( | ||
| "populateUploadableFlags Path1: entity={} has {} key fields; only '{}' is used for parentId lookup", |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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).
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 existThe 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:
Type of change
Please delete options that are not relevant.
Checklist before requesting a review
Upload Screenshots/lists of the scenarios tested