Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] errorKey is not set when pinoHttp is a tuple #2266

Open
4 tasks done
AndrewBird81 opened this issue Mar 1, 2025 · 1 comment
Open
4 tasks done

[BUG] errorKey is not set when pinoHttp is a tuple #2266

AndrewBird81 opened this issue Mar 1, 2025 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@AndrewBird81
Copy link

What is the current behavior?
PinoLogger's errorKey is not properly initialized when pinoHttp is supplied as a tuple.

Inside the PinoLogger constructor, the errorKey is initialized (or defaulted) as such:

if (
  typeof pinoHttp === 'object' &&
  'customAttributeKeys' in pinoHttp &&
  typeof pinoHttp.customAttributeKeys !== 'undefined'
) {
  this.errorKey = pinoHttp.customAttributeKeys.err ?? 'err';
}

However, the Options for pinoHttp could also be supplied as a tuple:

pinoHttp?: Options | DestinationStream | [Options, DestinationStream];

And when pinoHttp is supplied as the tuple [Options, DestinationStream], the above logic fails, resulting in this.errorKey being incorrectly defaulted to err, despite having a valid customAttributeKeys.err defined in the Options.

What is the expected behavior?
Users should be able to use any valid signature of pinoHttp without losing the ability to specify their errorKey.

Please provide minimal example repo, not code snippet. Without example repo this issue will be closed.
Sorry, I already spent my Saturday tracking down this bug. You can close this issue if you want, but a cursory glance will prove its validity.

Please mention other relevant information such as Node.js version and Operating System.
N/A

@AndrewBird81 AndrewBird81 added the bug Something isn't working label Mar 1, 2025
@iamolegga
Copy link
Owner

@AndrewBird81 thanks for opening this issue, would you like to open a PR for this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants