fauna-shell
fauna-shell copied to clipboard
Wrong error handling and wrong `exitCode`
Description
The way errors are handled by this tool make it near impossible to build other tools or scripts on top of it in a reliable manner.
As soon as an error is thrown, the script calling fauna is broken.
Here is an example of intended behaviour, but that fails as soon as an error is thrown.
Steps to reproduce the error:
1- Copy the code below into /tmp/role.fql:
CreateRole({ name: "user",
membership: [{ resource: Collection('User') }],
privileges: [
{
resource: Function('logout'),
actions: { call: true }
}
]
})
2- Run the code below (or any code that would trigger a remote error within fauna):
npx fauna eval --format=json --file=/tmp/role.fql && echo '\nSuccess! No error code!'
Output:
{
errors: [
...
...
]
}
Success! No error code!
Desired behaviour
- The
exitCodeshould clearly never be0when the output is an error (which would then not letSuccess! No error code!be shown). - The error message should go in the
stderrbut instead goes instdout. - The message has a JSON-like structure, but can't be parsed by any script because is not valid JSON.