deepkit-framework icon indicating copy to clipboard operation
deepkit-framework copied to clipboard

Improve errors for missing or misconfigured configuration options

Open Rush opened this issue 4 years ago • 0 comments

Currently the errors are pretty raw and useful mostly to developers:

ConfigurationInvalidError: Configuration for module root is invalid. Make sure the module is correctly configured. Error: redisPort(required): Required value is undefined

A robust configuration system should report:

  • locations (environment variables or config files) it tried to search if the value is missing
  • reporting on the config value that needs to be added, if missing (exact variable name, including prefix)
  • if validation failed, inform the user what is expected and what is the current value

Basically, a person non-familiar with the codebase should be able to operate a service that's using Deepkit's configuration system.

An example improved error could say:

Required redisHost config variable is missing. Expected CC_REDIS_HOST environment variable to be set. Looked for variables inside '.env'.

Rush avatar Sep 20 '21 02:09 Rush