cloud-sdk-js icon indicating copy to clipboard operation
cloud-sdk-js copied to clipboard

Client Generation fails for OData v4 service with EDMX Version 4.01

Open preetamkajalrout opened this issue 7 months ago • 6 comments

Describe the Bug

During generation of a client for OData v4, Generator fails to generate the client if edmx Version is 4.01 instead of 4.0. Both the versions are valid as mentioned in the OASIS ODATA documentation

Sample EDMX can be downloaded from SalesOrder (A2X) OData V4

Error Output

[2025-04-15T11:15:33.374Z] ERROR    (cli): ErrorWithCause: Generation of services failed.
    at /Users/<projectpath>/node_modules/@sap-cloud-sdk/generator/dist/cli.js:14:18
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
Caused by:
TypeError: Cannot read properties of undefined (reading 'split')
    at /Users/<projectpath>/node_modules/@sap-cloud-sdk/generator/dist/edmx-to-vdm/v2/entity.js:26:51
    at Array.map (<anonymous>)
    at navigationProperties (/Users/<projectpath>/node_modules/@sap-cloud-sdk/generator/dist/edmx-to-vdm/v2/entity.js:25:42)
    at /Users/<projectpath>/node_modules/@sap-cloud-sdk/generator/dist/edmx-to-vdm/v2/entity.js:19:31
    at Array.map (<anonymous>)
    at generateEntitiesV2 (/Users/<projectpath>/node_modules/@sap-cloud-sdk/generator/dist/edmx-to-vdm/v2/entity.js:17:29)
    at getServiceEntitiesV2 (/Users/<projectpath>/node_modules/@sap-cloud-sdk/generator/dist/edmx-to-vdm/v2/service-entities.js:14:54)
    at ServiceGenerator.generateService (/Users/<projectpath>/node_modules/@sap-cloud-sdk/generator/dist/service-generator.js:27:54)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async Promise.all (index 0)

Cloud SDK Generator Version

npx generate-odata-client --version provides output 4.0.2

Node version

Node version used 22.14.0

Steps to Reproduce

  1. Install the generator using following command as part of your project (local to your project)
npm install -D @sap-cloud-sdk/generator
  1. Execute the command to generate the client
npx generate-odata-client --input srv/external/CE_SALESORDER_0001.edmx  --outputDir srv/external/clients --verbose --optionsPerService srv/external --skipValidation --overwrite
  1. Command errors out without any files being created.
  2. Following Error sample is shown:
[2025-04-15T11:15:33.374Z] ERROR    (cli): ErrorWithCause: Generation of services failed.
    at /Users/<projectpath>/node_modules/@sap-cloud-sdk/generator/dist/cli.js:14:18
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
Caused by:
TypeError: Cannot read properties of undefined (reading 'split')
    at /Users/<projectpath>/node_modules/@sap-cloud-sdk/generator/dist/edmx-to-vdm/v2/entity.js:26:51
    at Array.map (<anonymous>)
    at navigationProperties (/Users/<projectpath>/node_modules/@sap-cloud-sdk/generator/dist/edmx-to-vdm/v2/entity.js:25:42)
    at /Users/<projectpath>/node_modules/@sap-cloud-sdk/generator/dist/edmx-to-vdm/v2/entity.js:19:31
    at Array.map (<anonymous>)
    at generateEntitiesV2 (/Users/<projectpath>/node_modules/@sap-cloud-sdk/generator/dist/edmx-to-vdm/v2/entity.js:17:29)
    at getServiceEntitiesV2 (/Users/<projectpath>/node_modules/@sap-cloud-sdk/generator/dist/edmx-to-vdm/v2/service-entities.js:14:54)
    at ServiceGenerator.generateService (/Users/<projectpath>/node_modules/@sap-cloud-sdk/generator/dist/service-generator.js:27:54)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async Promise.all (index 0)

Faster way to reproduce the error for contributors

  1. Change the version to 4.01 in sample file test-resources > odata-service-specs > v4 > API_TEST_SRV > API_TEST_SRV.edmx
  2. Run the generate command yarn generate or Run the test command yarn test
  3. Generation and Test cases would start failing

Expected Behavior

  1. Generation of client should succeed
  2. No errors should be displayed due to the version difference

Screenshots

No response

Used Versions

  • Node version via node -v: 22.14.0
  • NPM version via npm -v: 10.9.2
  • SAP Cloud SDK version: 4.0.2
  • For CAP users, CAP version: 8.8.2

Code Examples

No response

Log File

No response

Affected Development Phase

Getting Started

Impact

Blocked

Timeline

No response

Additional Context

No response

preetamkajalrout avatar Apr 15 '25 13:04 preetamkajalrout

Hi @preetamkajalrout, thanks for raising this issue & PR.

I've discussed this with our PO, and we came to the conclusion that for proper 4.X support, we would need to implement a longer list of new features, tests, etc.

Based on the demand, we can't prioritise proper support for this version yet.

As a workaround, you can adjust the line you've modified in your PR in the node_modules instead, or alternatively, fork the project with your PR's change in place.

Let me know if you need any assistance for the workaround.

tomfrenken avatar Apr 16 '25 11:04 tomfrenken

Adding our PO @jjtang1985 to the conversation, in case demand for this version increases.

tomfrenken avatar Apr 16 '25 11:04 tomfrenken

Hi @preetamkajalrout, thanks for raising this issue & PR.

I've discussed this with our PO, and we came to the conclusion that for proper 4.X support, we would need to implement a longer list of new features, tests, etc.

Based on the demand, we can't prioritise proper support for this version yet.

As a workaround, you can adjust the line you've modified in your PR in the node_modules instead, or alternatively, fork the project with your PR's change in place.

Let me know if you need any assistance for the workaround.

Hi @tomfrenken , I understand. I have been using the workaround for my current project. Thanks for your suggestion and would be happy to contribute in any capacity if this support is being implemented in future.

preetamkajalrout avatar Apr 17 '25 13:04 preetamkajalrout

Hi @preetamkajalrout,

I have added a BLI to track this issue. Please follow the item for further updates on the issue.

KavithaSiva avatar Apr 24 '25 08:04 KavithaSiva

Hi @preetamkajalrout,

I have added a BLI to track this issue. Please follow the item for further updates on the issue.

Hi @KavithaSiva , Thanks for creating a backlog item. But it looks like there is no way to follow the item. Probably I don't have access to the repository and it is not public. Can you guide me how I can follow the issue.

preetamkajalrout avatar Apr 24 '25 12:04 preetamkajalrout

Apologies, it is a private repo, I will keep this issue open instead to track progress.

KavithaSiva avatar Apr 29 '25 07:04 KavithaSiva