Rpc provision POST request with empty data causes otnode crash
Issue description
Sending publish request to a v6 node causes with empty data causes it to crash, for example like this : curl -X POST -H "Content-Type: application/json" 'http://localhost:8900/provision'
Expected behavior
No restart
Actual behavior
A restart
Steps to reproduce the problem
- Set up a otnode and run otnode-log
- Post a call with empty data string to publish data like this :
curl -X POST -H "Content-Type: application/json" 'http://localhost:8900/provision' - See how otnode-log shows the restart behaviour showed in the logs attached below.
Specifications
- Node version: 6.0.0-beta.1.38
- Platform: Ubuntu 20.04.4 , otnode is running native - not docker
- Node wallet: 0x104070ba9A9146AdE043c3380Bc20868566Bbd96
- Node libp2p identity:QmQ7o1JJvgiFshdNJHHuRaBGyA7VALsies5qiBPBqew1Es
Contact details
- Email: :)
Error logs
` [2022-07-26 18:34:22] DEBUG: Node QmQ7o1JJvgiFshdNJHHuRaBGyA7VALsies5qiBPBqew1Es connected to QmcruGfYtNW45Gs9DkzSoyxaSYwLT482V49SL5FFfuJfot Something went really wrong! OT-node shutting down... TypeError: Cannot read properties of undefined (reading 'data') at PublishController.isRequestValid (/root/ot-node/6.0.0-beta.1.38/src/controller/v1/publish-controller.js:149:23) at PublishController.handleHttpApiPublishMethod (/root/ot-node/6.0.0-beta.1.38/src/controller/v1/publish-controller.js:45:31) at PublishController.handleHttpApiProvisionRequest (/root/ot-node/6.0.0-beta.1.38/src/controller/v1/publish-controller.js:23:21) at /root/ot-node/6.0.0-beta.1.38/modules/controller/rpc-controller.js:218:46 at Layer.handle [as handle_request] (/root/ot-node/6.0.0-beta.1.38/node_modules/express/lib/router/layer.js:95:5) at next (/root/ot-node/6.0.0-beta.1.38/node_modules/express/lib/router/route.js:137:13) at /root/ot-node/6.0.0-beta.1.38/node_modules/express-slow-down/lib/express-slow-down.js:123:7 at MemoryStore.incr (/root/ot-node/6.0.0-beta.1.38/node_modules/express-slow-down/lib/memory-store.js:20:5) at slowDown (/root/ot-node/6.0.0-beta.1.38/node_modules/express-slow-down/lib/express-slow-down.js:45:19) at Layer.handle [as handle_request] (/root/ot-node/6.0.0-beta.1.38/node_modules/express/lib/router/layer.js:95:5) at next (/root/ot-node/6.0.0-beta.1.38/node_modules/express/lib/router/route.js:137:13) at /root/ot-node/6.0.0-beta.1.38/node_modules/express-rate-limit/dist/index.cjs:220:5 at processTicksAndRejections (node:internal/process/task_queues:96:5) at async /root/ot-node/6.0.0-beta.1.38/node_modules/express-rate-limit/dist/index.cjs:140:5 [2022-07-26 18:34:25] INFO: POST: /provision request received [2022-07-26 18:34:25] USERLVL: Started measuring execution of publish command [2022-07-26 18:34:25] USERLVL: Started measuring execution of check arguments for publishing otnode.service: Main process exited, code=exited, status=1/FAILURE otnode.service: Failed with result 'exit-code'. otnode.service: Scheduled restart job, restart counter is at 33. Stopped OriginTrail V6 Stage 1 Beta Node. Started OriginTrail V6 Stage 1 Beta Node. [2022-07-26 18:34:27] USERLVL: level-change [2022-07-26 18:34:27] INFO: ██████╗ ████████╗███╗ ██╗ ██████╗ ██████╗ ███████╗ [2022-07-26 18:34:27] INFO: ██╔═══██╗╚══██╔══╝████╗ ██║██╔═══██╗██╔══██╗██╔════╝ [2022-07-26 18:34:27] INFO: ██║ ██║ ██║ ██╔██╗ ██║██║ ██║██║ ██║█████╗ [2022-07-26 18:34:27] INFO: ██║ ██║ ██║ ██║╚██╗██║██║ ██║██║ ██║██╔══╝ [2022-07-26 18:34:27] INFO: ╚██████╔╝ ██║ ██║ ╚████║╚██████╔╝██████╔╝███████╗ [2022-07-26 18:34:27] INFO: ╚═════╝ ╚═╝ ╚═╝ ╚═══╝ ╚═════╝ ╚═════╝ ╚══════╝
`
Disclaimer
Please be aware that the issue reported on a public repository allows everyone to see your node logs, node details, and contact details. If you have any sensitive information, feel free to share it by sending an email to [email protected].