on 2024 Nov 01 11:52 AM
Hello all,
I've been scratching my head on the below, perhaps any of you has run into this issue or knows what is wrong?
When i run:
cds add http
I get the following error message. Please note that I redacted the username and project folder in the output (indicated with **).
PS C:\Users\**username**\code\**project name**> cds add http --filter ManagementService
Adding feature 'http'...
TypeError: Cannot read properties of undefined (reading 'concat')
at module.exports (C:\Users\**username**\AppData\Roaming\npm\node_modules\@sap\cds-dk\lib\init\template\data\as-json.js:62:29)
at async #generatePayload (C:\Users\**username**\AppData\Roaming\npm\node_modules\@sap\cds-dk\lib\init\template\http\index.js:135:5)
at async HttpTemplate.run (C:\Users\**username**\AppData\Roaming\npm\node_modules\@sap\cds-dk\lib\init\template\http\index.js:55:21)
at async CDSGenerator._process (C:\Users\**username**\AppData\Roaming\npm\node_modules\@sap\cds-dk\lib\init\index.js:154:13)
at async CDSGenerator.add (C:\Users\**username**\AppData\Roaming\npm\node_modules\@sap\cds-dk\lib\init\index.js:80:9)
at async Object.add (C:\Users\**username**\AppData\Roaming\npm\node_modules\@sap\cds-dk\bin\add.js:114:5)
at async Object.exec (C:\Users\**username**\AppData\Roaming\npm\node_modules\@sap\cds-dk\bin\cds.js:87:16)
Running
cds build --production
yield the following warnings (on imported API definitions):
[WARNING] srv\external\API_FUNCTIONALLOCATION.cds:204:3: Expected element name to be different from declaring ‹entity› (in entity:“API_FUNCTIONALLOCATION.Characteristic”/element:“Characteristic”)
[WARNING] srv\external\API_FUNCTIONALLOCATION.cds:291:7: Expected element name to be different from declaring ‹entity› (in entity:“API_FUNCTIONALLOCATION.FunctionalLocation”/element:“FunctionalLocation”)
[WARNING] srv\external\PRODUCT_0002.cds:84:9: “Auth.Http” is not a known vocabulary type for “@Authorization.Authorizations[1]” (in service:“PRODUCT_0002”/“@Authorization.Authorizations”)
[WARNING] srv\external\PRODUCT_0002.cds:84:9: “Auth.OAuth2AuthCode” is not a known vocabulary type for “@Authorization.Authorizations[0]” (in service:“PRODUCT_0002”/“@Authorization.Authorizations”)
[WARNING] srv\external\PRODUCT_0002.cds:84:9: “@Common.ApplyMultiUnitBehaviorForSortingAndFiltering” is experimental and can be changed or removed at any time, do not use productively! (in service:“PRODUCT_0002”/“@Common.ApplyMultiUnitBehaviorForSortingAndFiltering”)
[WARNING] srv\external\PRODUCT_0002.cds:95:8: Unexpected path value for “@Common.Messages” of type $(TYPE) (in entity:“PRODUCT_0002.ProdSalesDeliverySalesTax”/“@Common.Messages”)
[WARNING] srv\external\PRODUCT_0002.cds:261:8: Unexpected path value for “@Common.Messages” of type $(TYPE) (in entity:“PRODUCT_0002.Product”/“@Common.Messages”)
[WARNING] srv\external\PRODUCT_0002.cds:266:7: Expected element name to be different from declaring ‹entity› (in entity:“PRODUCT_0002.Product”/element:“Product”)
[WARNING] srv\external\PRODUCT_0002.cds:271:3: “@Common.SAPObjectNodeTypeReference” is experimental and can be changed or removed at any time, do not use productively! (in entity:“PRODUCT_0002.Product”/element:“ProductType”/“@Common.SAPObjectNodeTypeReference”)
[WARNING] srv\external\PRODUCT_0002.cds:672:3: “@Common.Composition” is experimental and can be changed or removed at any time, do not use productively! (in entity:“PRODUCT_0002.Product”/element:“_ProductDescription”/“@Common.Composition”)
[WARNING] srv\external\PRODUCT_0002.cds:702:8: Unexpected path value for “@Common.Messages” of type $(TYPE) (in entity:“PRODUCT_0002.ProductDescription”/“@Common.Messages”)
[WARNING] srv\external\PRODUCT_0002.cds:713:3: Expected element name to be different from declaring ‹entity› (in entity:“PRODUCT_0002.ProductDescription”/element:“ProductDescription”)
[WARNING] srv\external\PRODUCT_0002.cds:765:8: Unexpected path value for “@Common.Messages” of type $(TYPE) (in entity:“PRODUCT_0002.ProductEWMStorageType”/“@Common.Messages”)
[WARNING] srv\external\PRODUCT_0002.cds:960:8: Unexpected path value for “@Common.Messages” of type $(TYPE) (in entity:“PRODUCT_0002.ProductEWMWarehouse”/“@Common.Messages”)
[WARNING] srv\external\PRODUCT_0002.cds:1217:8: Unexpected path value for “@Common.Messages” of type $(TYPE) (in entity:“PRODUCT_0002.ProductPlant”/“@Common.Messages”)
[WARNING] srv\external\PRODUCT_0002.cds:1407:8: Unexpected path value for “@Common.Messages” of type $(TYPE) (in entity:“PRODUCT_0002.ProductPlantCosting”/“@Common.Messages”)
[WARNING] srv\external\PRODUCT_0002.cds:1488:8: Unexpected path value for “@Common.Messages” of type $(TYPE) (in entity:“PRODUCT_0002.ProductPlantForecast”/“@Common.Messages”)
[WARNING] srv\external\PRODUCT_0002.cds:1536:8: Unexpected path value for “@Common.Messages” of type $(TYPE) (in entity:“PRODUCT_0002.ProductPlantInspTypeSetting”/“@Common.Messages”)
[WARNING] srv\external\PRODUCT_0002.cds:1676:8: Unexpected path value for “@Common.Messages” of type $(TYPE) (in entity:“PRODUCT_0002.ProductPlantInternationalTrade”/“@Common.Messages”)
[WARNING] srv\external\PRODUCT_0002.cds:1769:8: Unexpected path value for “@Common.Messages” of type $(TYPE) (in entity:“PRODUCT_0002.ProductPlantMRP”/“@Common.Messages”)
[WARNING] srv\external\PRODUCT_0002.cds:1962:8: Unexpected path value for “@Common.Messages” of type $(TYPE) (in entity:“PRODUCT_0002.ProductPlantProcurement”/“@Common.Messages”)
[WARNING] srv\external\PRODUCT_0002.cds:2003:8: Unexpected path value for “@Common.Messages” of type $(TYPE) (in entity:“PRODUCT_0002.ProductPlantPurchaseTax”/“@Common.Messages”)
[WARNING] srv\external\PRODUCT_0002.cds:2039:8: Unexpected path value for “@Common.Messages” of type $(TYPE) (in entity:“PRODUCT_0002.ProductPlantQualityManagement”/“@Common.Messages”)
[WARNING] srv\external\PRODUCT_0002.cds:2108:8: Unexpected path value for “@Common.Messages” of type $(TYPE) (in entity:“PRODUCT_0002.ProductPlantSales”/“@Common.Messages”)
[WARNING] srv\external\PRODUCT_0002.cds:2185:8: Unexpected path value for “@Common.Messages” of type $(TYPE) (in entity:“PRODUCT_0002.ProductPlantStorage”/“@Common.Messages”)
[WARNING] srv\external\PRODUCT_0002.cds:2235:8: Unexpected path value for “@Common.Messages” of type $(TYPE) (in entity:“PRODUCT_0002.ProductPlantStorageLocation”/“@Common.Messages”)
[WARNING] srv\external\PRODUCT_0002.cds:2323:8: Unexpected path value for “@Common.Messages” of type $(TYPE) (in entity:“PRODUCT_0002.ProductPlantSupplyPlanning”/“@Common.Messages”)
[WARNING] srv\external\PRODUCT_0002.cds:2654:8: Unexpected path value for “@Common.Messages” of type $(TYPE) (in entity:“PRODUCT_0002.ProductPlantWorkScheduling”/“@Common.Messages”)
[WARNING] srv\external\PRODUCT_0002.cds:2764:8: Unexpected path value for “@Common.Messages” of type $(TYPE) (in entity:“PRODUCT_0002.ProductProcurement”/“@Common.Messages”)
[WARNING] srv\external\PRODUCT_0002.cds:2803:8: Unexpected path value for “@Common.Messages” of type $(TYPE) (in entity:“PRODUCT_0002.ProductQualityManagement”/“@Common.Messages”)
[WARNING] srv\external\PRODUCT_0002.cds:2857:8: Unexpected path value for “@Common.Messages” of type $(TYPE) (in entity:“PRODUCT_0002.ProductSales”/“@Common.Messages”)
[WARNING] srv\external\PRODUCT_0002.cds:2979:8: Unexpected path value for “@Common.Messages” of type $(TYPE) (in entity:“PRODUCT_0002.ProductSalesDelivery”/“@Common.Messages”)
[WARNING] srv\external\PRODUCT_0002.cds:3199:8: Unexpected path value for “@Common.Messages” of type $(TYPE) (in entity:“PRODUCT_0002.ProductStorage”/“@Common.Messages”)
[WARNING] srv\external\PRODUCT_0002.cds:3359:8: Unexpected path value for “@Common.Messages” of type $(TYPE) (in entity:“PRODUCT_0002.ProductUnitOfMeasure”/“@Common.Messages”)
[WARNING] srv\external\PRODUCT_0002.cds:3491:8: Unexpected path value for “@Common.Messages” of type $(TYPE) (in entity:“PRODUCT_0002.ProductUnitOfMeasureEAN”/“@Common.Messages”)
[WARNING] srv\external\PRODUCT_0002.cds:3583:8: Unexpected path value for “@Common.Messages” of type $(TYPE) (in entity:“PRODUCT_0002.ProductValuation”/“@Common.Messages”)
[WARNING] srv\external\PRODUCT_0002.cds:3742:8: Unexpected path value for “@Common.Messages” of type $(TYPE) (in entity:“PRODUCT_0002.ProductValuationAccounting”/“@Common.Messages”)
[WARNING] srv\external\PRODUCT_0002.cds:3856:8: Unexpected path value for “@Common.Messages” of type $(TYPE) (in entity:“PRODUCT_0002.ProductValuationCosting”/“@Common.Messages”)
[WARNING] srv\external\PRODUCT_0002.cds:3964:8: Unexpected path value for “@Common.Messages” of type $(TYPE) (in entity:“PRODUCT_0002.ProductValuationLedgerAccount”/“@Common.Messages”)
[WARNING] srv\external\PRODUCT_0002.cds:4057:8: Unexpected path value for “@Common.Messages” of type $(TYPE) (in entity:“PRODUCT_0002.ProductValuationLedgerPrices”/“@Common.Messages”)
[WARNING] srv\management-service.cds:15:12: Expected element name to be different from declaring ‹entity› (in entity:“ManagementService.ProductionSupplyArea”/element:“ProductionSupplyArea”)
[WARNING] srv\management-service.cds:16:12: Expected element name to be different from declaring ‹entity› (in entity:“ManagementService.FunctionalLocation”/element:“FunctionalLocation”)
[WARNING] srv\management-service.cds:17:12: Expected element name to be different from declaring ‹entity› (in entity:“ManagementService.BusinessPartner”/element:“BusinessPartner”)
[WARNING] srv\management-service.cds:18:12: Expected element name to be different from declaring ‹entity› (in entity:“ManagementService.Customer”/element:“Customer”)
[WARNING] srv\management-service.cds:20:12: Expected element name to be different from declaring ‹entity› (in entity:“ManagementService.Product”/element:“Product”)
[WARNING] srv\management-service.cds:20:12: “@Common.Composition” is experimental and can be changed or removed at any time, do not use productively! (in entity:“ManagementService.Product”/element:“_ProductDescription”/“@Common.Composition”)
[WARNING] srv\management-service.cds:20:12: Unexpected path value for “@Common.Messages” of type $(TYPE) (in entity:“ManagementService.Product”/“@Common.Messages”)
[WARNING] srv\management-service.cds:21:12: Unexpected path value for “@Common.Messages” of type $(TYPE) (in entity:“ManagementService.ProductPlant”/“@Common.Messages”)
[WARNING] srv\management-service.cds:22:12: Unexpected path value for “@Common.Messages” of type $(TYPE) (in entity:“ManagementService.ProductPlantMRP”/“@Common.Messages”)
[WARNING] srv\management-service.cds:23:12: Expected element name to be different from declaring ‹entity› (in entity:“ManagementService.ProductDescription”/element:“ProductDescription”)
[WARNING] srv\management-service.cds:23:12: Unexpected path value for “@Common.Messages” of type $(TYPE) (in entity:“ManagementService.ProductDescription”/“@Common.Messages”)
[WARNING] srv\management-service.cds:24:12: Expected element name to be different from declaring ‹entity› (in entity:“ManagementService.KanbanControlCycle”/element:“KanbanControlCycle”)
I'm using the below cds version.
cds --version
@cap-js/asyncapi: 1.0.2
@cap-js/cds-types: 0.6.5
@cap-js/db-service: 1.14.0
@cap-js/openapi: 1.0.6
@cap-js/postgres: 1.10.1
@cap-js/sqlite: 1.7.4
@sap/cds: 8.3.1
@sap/cds-compiler: 5.3.2
@sap/cds-dk: 8.3.0
@sap/cds-dk (global): 8.3.0
@sap/cds-fiori: 1.2.7
@sap/cds-foss: 5.0.1
@sap/cds-mtxs: 2.2.0
@sap/eslint-plugin-cds: 3.1.0
Node.js: v20.18.0
**projectname**: 1.0.0
Request clarification before answering.
Hi @Nicolaas ,
It seems like a bug in @sap/cds-dk.
I managed to fix it locally by adding the following line to as-json.js right before the line where the crash happens (#62):
if (!data[name]) continue
so the fragment will looke like:
for (let i = 0; i < numRecordsToGenerate; i++) {
fillRecord(records[i], idNum+i, entity, csn, data, null, 0, referenceData)
}
if (!data[name]) continue
data[name] = data[name].concat(records) // append the new records to the possibly existingand referenced records
// remove records w/ duplicate keys. This can happen if the key is an enum (and we have less enum values than requested records).
data[name] = uniqRecords(data[name], entity)
In your case the path for as-json.js is C:\Users\**username**\AppData\Roaming\npm\node_modules\@sap\cds-dk\lib\init\template\data\as-json.js, you can navigate there from VSCode terminal by Ctrl+Click (or Cmd+Click in Mac)
Regards,
Peter
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
74 | |
30 | |
9 | |
7 | |
7 | |
6 | |
6 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.