node-config icon indicating copy to clipboard operation
node-config copied to clipboard

[BUG] Environment variable substitution fails silently if "__format" parser is not supported

Open KalleV opened this issue 1 year ago • 1 comments

Describe the bug Defining a custom-environment-variables.json file with "__format" definitions that do not match a supported parser leads to the configuration being silently ignored.

Example:

{
  "hostname": {
    "__name": "HOSTNAME",
    "__format": "string"
  }
}

Expected behavior An error when attempting to use an unsupported parser.

Screenshots N/A

Please tell us about your environment:

  • node-config version: 3.3.9
  • node-version: 20.x

Other information

Related code:

  • https://github.com/node-config/node-config/blob/8c52ea28863bdf1562b896ea1f75dada7a0ad11e/lib/config.js#L897-L902
  • https://github.com/node-config/node-config/blob/8c52ea28863bdf1562b896ea1f75dada7a0ad11e/lib/config.js#L1103-L1113

KalleV avatar Dec 11 '23 18:12 KalleV

Agreed it would be an improvement to either output an error message or throw an error if an unknown parser is specified.

lorenwest avatar Dec 11 '23 19:12 lorenwest