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:
|
util.parseString = function (content, format) { |
|
const parser = Parser.getParser(format); |
|
if (typeof parser === 'function') { |
|
return parser(null, content); |
|
} |
|
}; |
|
if ('__name' in value && '__format' in value && typeof vars[value.__name] !== 'undefined' && vars[value.__name] !== '') { |
|
try { |
|
const parsedValue = util.parseString(vars[value.__name], value.__format); |
|
} catch(err) { |
|
err.message = '__format parser error in ' + value.__name + ': ' + err.message; |
|
throw err; |
|
} |
|
util.setPath(result, pathTo.concat(prop), parsedValue); |
|
} else { |
|
_substituteVars(value, vars, pathTo.concat(prop)); |
|
} |
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:
Other information
Related code:
node-config/lib/config.js
Lines 897 to 902 in 8c52ea2
node-config/lib/config.js
Lines 1103 to 1113 in 8c52ea2