dyne / restroom-mw

🛠 Easy REST API builder executing Zencode
https://restroom.dyne.org
GNU Affero General Public License v3.0
3 stars 11 forks source link

Using `Rule caller restroom-mw` and adding some non json data as input crashes Apiroom #253

Open matteo-cristino opened 1 year ago

matteo-cristino commented 1 year ago

Using any script in Apiroom that contains Rule caller restroom-mw, for example

Rule caller restroom-mw
Scenario 'ecdh': Create the key

Given nothing
When I create the ecdh key
Then print the 'keyring'

and add some data as input that is not in json format, for example

What is this?

Apiroom will crash showing a grey screen.

Testing it from restroom API, without Apiroom, it returns the following message:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>SyntaxError: Unexpected token W in JSON at position 27<br> &nbsp; &nbsp;at JSON.parse (&lt;anonymous&gt;)<br> &nbsp; &nbsp;at parse (/home/matteo/src/db_restroom/node_modules/body-parser/lib/types/json.js:89:19)<br> &nbsp; &nbsp;at /home/matteo/src/db_restroom/node_modules/body-parser/lib/read.js:128:18<br> &nbsp; &nbsp;at AsyncResource.runInAsyncScope (node:async_hooks:203:9)<br> &nbsp; &nbsp;at invokeCallback (/home/matteo/src/db_restroom/node_modules/raw-body/index.js:231:16)<br> &nbsp; &nbsp;at done (/home/matteo/src/db_restroom/node_modules/raw-body/index.js:220:7)<br> &nbsp; &nbsp;at IncomingMessage.onEnd (/home/matteo/src/db_restroom/node_modules/raw-body/index.js:280:7)<br> &nbsp; &nbsp;at IncomingMessage.emit (node:events:525:35)<br> &nbsp; &nbsp;at endReadableNT (node:internal/streams/readable:1358:12)<br> &nbsp; &nbsp;at processTicksAndRejections (node:internal/process/task_queues:83:21)</pre>
</body>
</html>
puria commented 1 year ago

@matteo-cristino 🤔 thanks