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

fix: wrong array being iterated #139

Closed
wants to merge 1 commit into from

Conversation

rohit-gohri
Copy link

@rohit-gohri rohit-gohri commented Dec 9, 2020

Saw this error while seeing the code as reference for pinojs/pino-http-print#9

Copy link
Member

@jsumners jsumners left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we cover this with a unit test?

@rohit-gohri
Copy link
Author

Can we cover this with a unit test?

I'm not sure how since this wasn't causing any errors/bugs, because of this check just below: https://github.com/rohit-gohri/pino-pretty/blob/585c0bb7999b6cfc52e06b1e951e267f8758b809/lib/utils.js#L315

@jsumners
Copy link
Member

jsumners commented Dec 9, 2020

Compare an object that doesn't iterate correctly prior to the change with a known good output.

@rohit-gohri
Copy link
Author

Compare an object that doesn't iterate correctly prior to the change with a known good output.

That's what I'm saying, even though the wrong array was being iterated the output was already correct because the value was compared against undefined before doing anything with it:

https://github.com/rohit-gohri/pino-pretty/blob/585c0bb7999b6cfc52e06b1e951e267f8758b809/lib/utils.js#L310-L316

@mcollina
Copy link
Member

mcollina commented Dec 9, 2020

If it access the wrong index, it could result printing the wrong value maybe? The test could verify if there are no spurious keys.

@mcollina
Copy link
Member

Close with no activity.

@mcollina mcollina closed this May 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants