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

assert: handle undefined filename in getErrMessage #20848

Closed

Conversation

jeysal
Copy link
Contributor

@jeysal jeysal commented May 20, 2018

When generating an assertion error message,
filename might be undefined,
e.g. if assert is called in eval.

Handle this case gracefully instead of failing with
Cannot read property 'endsWith' of undefined.

Fixes: #20847

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added the assert Issues and PRs related to the assert subsystem. label May 20, 2018
@BridgeAR
Copy link
Member

@jeysal thanks a lot for reporting and fixing this!

@BridgeAR
Copy link
Member

@BridgeAR BridgeAR added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. fast-track PRs that do not need to wait for 48 hours to land. labels May 20, 2018
Copy link
Member

@benjamingr benjamingr left a comment

Choose a reason for hiding this comment

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

Excellent first contribution - good job!

@benjamingr
Copy link
Member

CI failures look unrelated. Retried just in case https://ci.nodejs.org/job/node-test-commit/18635/console

@apapirovski
Copy link
Member

Just my 2c but wouldn't we prefer to just bail out early before even checking the Map? Then we don't need to store extra values or run all that extra code...

@BridgeAR
Copy link
Member

@apapirovski we could bail out right after checking for a filename but that should not make a significant difference.

@jeysal
Copy link
Contributor Author

jeysal commented May 21, 2018

I guess that would indeed save some cache entries. Might look nicer to have both exit conditions in one place though. Would anyone else prefer splitting them?

@BridgeAR
Copy link
Member

@jeysal if you do not mind, moving would be better.

@jeysal jeysal force-pushed the assert-error-message-undefined-filename branch from d267d28 to 86b8330 Compare May 21, 2018 12:30
When generating an assertion error message,
`filename` might be undefined,
e.g. if `assert` is called in `eval`.

Handle this case gracefully instead of failing with
`Cannot read property 'endsWith' of undefined`.

Fixes: nodejs#20847
@jeysal jeysal force-pushed the assert-error-message-undefined-filename branch from 86b8330 to 0118fcd Compare May 21, 2018 12:32
@jeysal
Copy link
Contributor Author

jeysal commented May 21, 2018

done

Copy link
Member

@BridgeAR BridgeAR left a comment

Choose a reason for hiding this comment

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

Still LG

@jasnell
Copy link
Member

jasnell commented May 23, 2018

Way too much red and yellow in the last CI run, trying again: https://ci.nodejs.org/job/node-test-pull-request/15055/

@jasnell
Copy link
Member

jasnell commented May 23, 2018

Still a lot of red in the CI but none of it related.

jasnell pushed a commit that referenced this pull request May 23, 2018
When generating an assertion error message,
`filename` might be undefined,
e.g. if `assert` is called in `eval`.

Handle this case gracefully instead of failing with
`Cannot read property 'endsWith' of undefined`.

Fixes: #20847

PR-URL: #20848
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Khaidi Chu <i@2333.moe>
Reviewed-By: James M Snell <jasnell@gmail.com>
@jasnell
Copy link
Member

jasnell commented May 23, 2018

Landed in a5d86f8

@jasnell jasnell closed this May 23, 2018
@jeysal jeysal deleted the assert-error-message-undefined-filename branch May 23, 2018 15:53
targos pushed a commit that referenced this pull request May 25, 2018
When generating an assertion error message,
`filename` might be undefined,
e.g. if `assert` is called in `eval`.

Handle this case gracefully instead of failing with
`Cannot read property 'endsWith' of undefined`.

Fixes: #20847

PR-URL: #20848
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Khaidi Chu <i@2333.moe>
Reviewed-By: James M Snell <jasnell@gmail.com>
@MylesBorins MylesBorins mentioned this pull request May 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assert Issues and PRs related to the assert subsystem. author ready PRs that have at least one approval, no pending requests for changes, and a CI started. fast-track PRs that do not need to wait for 48 hours to land.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

assert: filename may be undefined in filename.endsWith('.js')
10 participants