Fix populateUploadableFlags breaks reads on non-draft services#532
Open
yashmeet29 wants to merge 3 commits into
developcap-java/sdm:developfrom
SDMEXT-nonDraftServiceIssue-featurecap-java/sdm:SDMEXT-nonDraftServiceIssue-featureCopy head branch name to clipboard
Open
Fix populateUploadableFlags breaks reads on non-draft services#532yashmeet29 wants to merge 3 commits intodevelopcap-java/sdm:developfrom SDMEXT-nonDraftServiceIssue-featurecap-java/sdm:SDMEXT-nonDraftServiceIssue-featureCopy head branch name to clipboard
yashmeet29 wants to merge 3 commits into
developcap-java/sdm:developfrom
SDMEXT-nonDraftServiceIssue-featurecap-java/sdm:SDMEXT-nonDraftServiceIssue-featureCopy head branch name to clipboard
Conversation
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
Fix: HTTP 500 on plain reads from non-draft services with SDM-annotated attachments
Problem
Bumping SDM from 1.9.x to 1.10.0 caused every OData GET request returning ≥1 row from a non-draft service to fail with HTTP 500:
CdsElementNotFoundException: No element with name 'IsActiveEntity' in
'..fileContent'
(service 'PersistenceService$Default', event 'READ')
at DBQuery.getAttachmentsForUPID(DBQuery.java:57)
at SDMReadAttachmentsHandler.lambda$populateUploadableFlags$3(SDMReadAttachmentsHandler.java:493)
Root cause: populateUploadableFlags is a new @after handler introduced in 1.10.0 that runs on every successful read of any entity whose composition carries @SDM.Attachments.maxCount. When the parent entity returns rows, it calls DBQuery.getAttachmentsForUPID, which unconditionally SELECTs IsActiveEntity. CAP only generates that element on entities under a @odata.draft.enabled service — non-draft services don't have it, so the CQN model resolution throws at query-build time.
The same latent assumption exists in getAttachmentsForUPIDAndRepository and getAttachmentsForFolder, but those methods were only reachable via attachment-side actions (upload/download/delete) which non-draft services typically don't expose. populateUploadableFlags is the first SDM handler to put this assumption on the plain parent-read path.
Fix
Two targeted changes, matching the defensive pattern already established in resolveAttachmentEntityForCount and populateUploadableFlagsViaUp:
SDMReadAttachmentsHandler.populateUploadableFlags
Compute entityHasDraftSupport once per handler invocation using target.findElement("IsActiveEntity").isPresent()
Gate rowIsDraft on that flag — non-draft entities always resolve to false (active) without attempting to read an absent field
DBQuery.getAttachmentsForUPID / getAttachmentsForUPIDAndRepository / getAttachmentsForFolder (active-entity fallback)
Build the SELECT column list dynamically
Only include "IsActiveEntity" when attachmentEntity.findElement("IsActiveEntity").isPresent()
Type of change
Please delete options that are not relevant.
Checklist before requesting a review
Upload Screenshots/lists of the scenarios tested