cancel
Showing results for 
Search instead for 
Did you mean: 

Regarding the "The service metadata is invalid" error in the SAP Fiori generator

cothe
Explorer
398

When adding a UI app with the SAP Fiori generator, I encountered an error stating, "The service metadata is invalid."

SAP Fiori generator

cothe_0-1729868560066.png

Console messages in the developer tool.

cothe_1-1729868957157.png

services.cds

 

using {my} from '../db/schema';

service MyService {
    entity Foo as projection on my.Foo;
}

 

schema.cds

 

namespace my;

entity Foo {
    key ID    : Integer;
        value : String;
}

 

 

I'm not sure what metadata this message refers to. The error occurred while following the tutorial at this SAP path.

To reproduce the issue, I created an empty project using cds init projectname, added a services.cds file under the srv path, and defined a simple service. Despite this, the same error still appears.

I've tried reinstalling plugins and even reinstalled VS Code, but nothing has worked so far.

Could you suggest where else I should check?

I'm working on macOS and VS Code, both updated to the latest versions.

Thank you.

View Entire Topic
cothe
Explorer
0 Kudos

I have resolved the issue.
After adding the following configuration to package.json and restarting VS Code, it started working correctly.

"cds": {
    "requires": {
      "db": {
        "kind": "sqlite",
        "credentials": {
          "database": ":memory:"
        }
      }
    }
  }

Restarting VS Code was necessary to fix the issue.

However, this seems to be a workaround, so there still appears to be an underlying problem. It looks like the plugin needs improvement.

When the issue occurred, I checked the logs and found the following type-related error:

 

[2024-10-27 22:54:36] ERROR: An error occurred reading CAP service metadata: FooService. See log for more details.
[2024-10-27 22:54:36] ERROR: Error: Error while reading CAP service metadata. Path: '/Users/cothe/VSCodeProjects/SAP/sample2', service uri: '/odata/v4/foo/', error: 'TypeError: Cannot read properties of undefined (reading 'includes')'}

 

Thanks.

JulianZankl
Discoverer
0 Kudos
I have the same issue as you described above, but unfortunately this solution did not solve the problem for me 😕
cothe
Explorer
0 Kudos

This is such a strange issue, and I hope it gets resolved soon.

If there is a database setting defined in a higher-level (high-priority) configuration file, try deleting it, leaving only the sqlite section in package.json. Then, restart VS Code and try again.

In my case, I had provided the DB connection info in .cdsrc-private.json, and it stopped working, so I deleted it and tried again, which made it work.

This is truly odd. I really hope it gets fixed soon.

ref @JulianZankl 

 

@cap-js/asyncapi: 1.0.2
@cap-js/db-service: 1.14.1
@cap-js/openapi: 1.0.5
@sap/cds: 8.4.1
@sap/cds-compiler: 5.4.2
@sap/cds-dk: 8.1.2
@sap/cds-dk (global): 8.3.0
@sap/cds-fiori: 1.2.7
@sap/cds-foss: 5.0.1
@sap/cds-mtxs: 2.0.5
@sap/eslint-plugin-cds: 3.0.4
Node.js: v20.15.0
CAP Java SDK: 3.2.0
cds4j: 3.2.0
Spring Boot: 3.3.3
Maven: 3.9.9
Java: 21.0.3(Eclipse Adoptium) for windows, 21.0.5(sapjvm) for mac
OS: Windows 11, 10.0, arch: amd64
Max OS X, 15.0.1, arch: aarch64

 

SAP Cloud Application Programming Model 

SAP Fiori Elements 

 

JulianZankl
Discoverer
0 Kudos
I actually managed to get it working last week by using the npm package "yo" which allows the creation of UIs inside the cmd. I have not tested the proposed solution of yours, but that could actually be the case as I also used a ".env" file for database credentials. Really hope this gets fixed soon tho as it's still easier to use the Fiori Generator for the given task ref @cothe