cancel
Showing results for 
Search instead for 
Did you mean: 

Issue with Deep Entity Request in CAP (cds.validate issue - cds v 8.3.0)

cbsmerveguel
Explorer
0 Kudos
99

Hi all,

I’ve established a basic parent-child association in my SAP on-premise backend and am consuming this OData service in my CAP application. However, while attempting to send a deep entity request to the backend, I consistently encountered the following error message:

'Property "0" does not exist in XXXItemSet'.

At first, I suspected an issue with our backend design, but after reviewing it thoroughly, we turned our attention to CAP since nothing seemed amiss with the backend.

The error message originated from the file /node_modules/@sap/cds/lib/linked/validate.js, and after some debugging, we identified the problematic check at line 202 (@sap/cds version 8.3.0):

 

 

else if (d['@cds.validate'] !== false) d.validate(data[each], path_, ctx)

 

 

At this point, the system loops through the metadata elements and their properties (those from the CSN file) for the parent entity set (XXXSet), which works fine. However, when it reaches the association and attempts to validate its elements, it fails. The system assumes that there is a @CDS.validate property in the association, but when it can't find it, it misinterprets the element list, and misunderstands the first element in the child item set as the property "0" (basically the first array count), causing the error.

To test this, I modified the CSN file by manually appending the @CDS.validateas false property to the generated association element. This allowed me to bypass the check and proceed with the process, eventually reaching the backend method successfully. Here’s the updated part of the CSN file:

 

    "XXXItemSet": {
     "@cds.validate": false,
     "type": "cds.Association",
     "target": "Dummy_SRV.XXXItemSet",
     "cardinality": {
      "max": "*"
     },
     "keys": []
    },

 

 

According to the Capire documentation the @CDS.validate functionality was introduced in the June 2024 (cds 8.0.3) release. If we downgrade to cds version 7.9.4, the issue does not occur, which leads me to believe that this might either be a bug related to deep entity creation or there’s an additional step we’ve missed with this new validation process.
 
We would greatly appreciate any explanation or solution that avoids downgrading to the previous release or manually editing the CSN file.

Any guidance or insights would be greatly appreciated!

Thanks!
Merve

cbsmerveguel
Explorer
0 Kudos
Note: The cds_validate property was also set to false in the "cds/features" configuration within the package.json, as outlined in the attached June 2024 Capire documentation. However, did not have a positive effect on the issue.

Accepted Solutions (0)

Answers (0)