Closed tuckbick closed 3 years ago
There might be some bugs! Would you like to upload an example that reproduce the problem? Also, sending a PR would be handy.
I think this might be a bug in https://www.npmjs.com/package/fast-redact.
cc @davidmarkclements
I wouldn't expect any software to be completely free of bugs š
Here's a repo here that reproduces the problem: https://github.com/tuckbick/test-hapi-pino
This could instead be a problem in pino-pretty
, as this only occurs while piping stdout through pino-pretty
instead of using the prettyPrint
option.
Iām failing to understand how using prettyPrint internally can avoid this. Anyway, it seems you have identified where there is a bug.. would you like to send a PR to pino to fix?
Yep, sure thing. I'll try to get PR together this week!
Haven't gotten to a PR yet -- not quite sure where to put a fix yet. However, I've done some investigation:
pinoPretty: true
, pino
does some programmatic redaction here, stringifying the object, thus removing undefined
properties.pinoPretty: false
, the object is logged to stdout containing the undefined properties.You need to add another if
in https://github.com/pinojs/pino/blob/master/lib/tools.js#L107 to handle the case that value
could be undefined
and in that case not include the key as well.
Thanks for the direction! Please see the submitted PR.
Merged in https://github.com/pinojs/pino/pull/756
In the configuration options below,
responseTime
is a redacted path:This results in a log that contains invalid JSON (see
undefined
):I recognize that this is probably a
pino
issue, but it's only occurring for me when redactingresponseTime
, a value calculated inhapi-pino
.I believe the issue has to do with the
stringifier
inpino
here.