-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: Cannot convert undefined or null to object #115
Comments
Thanks for reporting the issue and for the details to reproduce the error, I will have a look asap. |
I made the request data processing more stable with 16ab786. I will provide a new release start of next week. In general: The way you are calling OData V2 action with POST is not 100% conforming to OData V2 standard. Addressing Service Operations This of course limits the action parameters to simple data types, without nesting structures. That's why I also allow non-conformant action POST bodies like in OData V4, because I find the usage way more natural ;-) |
Thank you very much for the update! |
1.14.0 is released: https://github.com/cap-js-community/odata-v2-adapter/releases/tag/v1.14.0 |
Hello,
After migrating to the @cap-js-community/odata-v2-adapter package, we found a problem in the payload management of some calls.
If null properties are passed in the odata body, this error is generated, which did not happen with @sap/cds-odata-v2-adapter-proxy.
In the following repository, you can see the anomaly: https://github.com/conse-srl/test_CAP
Steps to reproduce the error:
Start the server with the “start” command in the package.json.
Use the “test.http” file to make the POST “{{catService}}/saveElements” call.
The library will fail:
[cov2ap] - Request: TypeError: Cannot convert undefined or null to object at /home/user/projects/test_CAP/node_modules/@cap-js-community/odata-v2-adapter/src/index.js:2636:7 at Array.forEach (<anonymous>) at convertRequestData (/home/user/projects/test_CAP/node_modules/@cap-js-community/odata-v2-adapter/src/index.js:2635:10) at convertRequestData (/home/user/projects/test_CAP/node_modules/@cap-js-community/odata-v2-adapter/src/index.js:2628:14) at /home/user/projects/test_CAP/node_modules/@cap-js-community/odata-v2-adapter/src/index.js:2652:13 at Array.forEach (<anonymous>) at /home/user/projects/test_CAP/node_modules/@cap-js-community/odata-v2-adapter/src/index.js:2642:25 at Array.forEach (<anonymous>) at convertRequestData (/home/user/projects/test_CAP/node_modules/@cap-js-community/odata-v2-adapter/src/index.js:2641:10) at convertRequestData (/home/user/projects/test_CAP/node_modules/@cap-js-community/odata-v2-adapter/src/index.js:2628:14) [cov2ap] - Request: Request with Error { method: 'POST', url: '/cat/saveElements', target: 'http://localhost:4004' } [odata] - POST /cat/saveElements [cov2ap] - [HPM] POST /odata/v2/cat/saveElements -> http://localhost:4004/cat/saveElements [408] [cds] - BadRequestError: request aborted at IncomingMessage.onAborted (/home/user/projects/test_CAP/node_modules/raw-body/index.js:245:10) at IncomingMessage.emit (node:events:518:28) at IncomingMessage._destroy (node:_http_incoming:224:10) at _destroy (node:internal/streams/destroy:121:10) at IncomingMessage.destroy (node:internal/streams/destroy:83:5) at abortIncoming (node:_http_server:794:9) at socketOnClose (node:_http_server:788:3) at Socket.emit (node:events:530:35) at TCP.<anonymous> (node:net:337:12) at TCP.callbackTrampoline (node:internal/async_hooks:130:17) { code: 'ECONNABORTED', expected: 619, length: 619, received: 0, type: 'request.aborted', statusCode: 400 } [error] - 400 > { message: 'request aborted', code: 'ECONNABORTED' }
Regards,
Kevin
The text was updated successfully, but these errors were encountered: