-
Notifications
You must be signed in to change notification settings - Fork 507
[BUG] Environment variable substitution fails silently if "__format" parser is not supported #753
Copy link
Copy link
Open
Labels
breaking-changebuggood-first-issueIssues suitable for people learning the libraryIssues suitable for people learning the librarypr-welcome
Milestone
Description
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:
Lines 897 to 902 in 8c52ea2
util.parseString = function (content, format) { const parser = Parser.getParser(format); if (typeof parser === 'function') { return parser(null, content); } }; Lines 1103 to 1113 in 8c52ea2
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)); }
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
breaking-changebuggood-first-issueIssues suitable for people learning the libraryIssues suitable for people learning the librarypr-welcome