Description
Describe the bug
The code that reads the config file is wrapped in a single bare exception catch: https://github.com/enketo/enketo/blob/7.5.0/packages/enketo-express/app/models/config-model.js#L30
This means that for all of the following examples:
- a missing file
- lack of permission to read
- syntax error in json parsing
the same error will get logged: No local config.json found. Will check environment variables instead.
To Reproduce
- For example purposefully break the config syntax by let's say a missing end quote on a string value.
- Observe the error message in the logs
Expected behavior
The error message should not mislead.
IMO if the problem is anything other than a missing file the processing should loudly fail instead of continuing – if the config file exists it's clearly meant to be read, so continuing with defaults could be risky if the defaults still mean that the service is able to start. It'll then silently have different config than expected.
Browser and OS (please complete the following information):
- OS/browser – irrelevant
ghcr.io/enketo/enketo:7.5.0
Additional context
Even if the file is missing, it might be due to mistaken paths. So it might be better to have an explicit setting that says to use env vars, but I realize that would be a breaking change.