Describe the bug
When logging errors with additional properties, the values are not masked
To Reproduce
Steps to reproduce the behavior:
const error = new Error();
Object.assign(error, {
extensions: {
serviceName: 'upstream-service',
variables: {
firstName: 'foo',
phoneNumber: 'bar'
}
}
});
const log = new Logger({
maskValuesOfKeys: ["firstName", "phoneNumber"],
type: "json"
})
log.info(error);
Outputs:
{
"nativeError": {
"extensions": {
"serviceName": "upstream-service",
"variables": {
"firstName": "foo",
"phoneNumber": "bar"
}
}
},
"name": "Error",
"message": "Example error",
"stack": [ ],
"_meta": { }
}
(stack and _meta are outputting properly, I'm just truncating them for the report.)
Expected behavior
Properties and sub-properties of Errors should be masked, eg:
{
"nativeError": {
"extensions": {
"serviceName": "upstream-service",
"variables": {
"firstName": "[***]",
"phoneNumber": "[***]"
}
}
},
"name": "Error",
"message": "Example error",
"stack": [ ],
"_meta": { }
}
Additional context
The expected behaviour was the default behaviour previously, there seems to have been a change introduced in v4.4.0. The observed issue occurs with all versions from v4.4.0 to v4.7.2. The output of v4.3.1 is consistent with the expected output.
{
"nativeError": {
"extensions": {
"serviceName": "upstream-service",
"variables": {
"firstName": "[***]",
"phoneNumber": "[***]"
}
}
},
"name": "Error",
"message": "Example error",
"stack": [ ],
"_meta": { }
}
Node.js Version
e.g. 16.16.0
OS incl. Version
e.g. macOS 13.1
Describe the bug
When logging errors with additional properties, the values are not masked
To Reproduce
Steps to reproduce the behavior:
Outputs:
{ "nativeError": { "extensions": { "serviceName": "upstream-service", "variables": { "firstName": "foo", "phoneNumber": "bar" } } }, "name": "Error", "message": "Example error", "stack": [ ], "_meta": { } }(
stackand_metaare outputting properly, I'm just truncating them for the report.)Expected behavior
Properties and sub-properties of Errors should be masked, eg:
{ "nativeError": { "extensions": { "serviceName": "upstream-service", "variables": { "firstName": "[***]", "phoneNumber": "[***]" } } }, "name": "Error", "message": "Example error", "stack": [ ], "_meta": { } }Additional context
The expected behaviour was the default behaviour previously, there seems to have been a change introduced in
v4.4.0. The observed issue occurs with all versions fromv4.4.0tov4.7.2. The output ofv4.3.1is consistent with the expected output.{ "nativeError": { "extensions": { "serviceName": "upstream-service", "variables": { "firstName": "[***]", "phoneNumber": "[***]" } } }, "name": "Error", "message": "Example error", "stack": [ ], "_meta": { } }Node.js Version
e.g. 16.16.0
OS incl. Version
e.g. macOS 13.1