-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
esm: identify parent importing a url with invalid host #49736
esm: identify parent importing a url with invalid host #49736
Conversation
Review requested:
|
lib/internal/errors.js
Outdated
E('ERR_INVALID_FILE_URL_HOST', | ||
'File URL host must be "localhost" or empty on %s', TypeError); | ||
E('ERR_INVALID_FILE_URL_HOST', (url, platform, base) => { | ||
let msg = `File URL host in ${url}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not pass the base and url to this just like in err_invalid_url?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the comment within err_invalid_url
that's probably a good idea!
495cf11
to
331c950
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we please add a test?
TypeError [ERR_INVALID_FILE_URL_HOST]: File URL host must be "localhost" or empty on darwin
On darwin? You mean the rules differ by platform?
Yep. MacOS + Linux vs Windows. |
So we should have tests for both versions of the error message. CI can validate the Windows one. We should also make the platform name friendly, like translate “darwin” to “macOS” and “win32” to “Windows”, and maybe everything else gets “POSIX platforms”. What is the rule for Windows? |
That sounds rather out of scope for the issue this is fixing. There is already a test for the underlying util that handles this. All I'm doing here is appending some properties to the error, not changing its message. |
Oh, I thought the message itself was the new part. I totally didn’t notice these extra properties. Why not put them into the message itself, in addition to where they are now? |
I did that at first, but it was rather dirty: The info was not available (so it involved a lot of daisy-chaining), and this augmentation isn't applicable to any other uses of the underlying util. Also embedding the url in the message can leak data in logging. |
Can there be a test to cover this change? |
Ordinarily I would've included one already, but this applies to only POSIX platforms, and I don't know how to mark a test-case as being applicable to only a certain platform. |
Just put |
Commit Queue failed- Loading data for nodejs/node/pull/49736 ✔ Done loading data for nodejs/node/pull/49736 ----------------------------------- PR info ------------------------------------ Title esm: identify parent importing a url with invalid host (#49736) ⚠ Could not retrieve the email or name of the PR author's from user's GitHub profile! Branch JakobJingleheimer:fix/esm-specifier-invalid-url-host -> nodejs:main Labels errors, whatwg-url, esm, needs-ci, commit-queue-squash Commits 3 - esm: identify parent importing a url with invalid host - test: add case for invalid posix host - fixup!: de-lint Committers 1 - Jacob Smith <3012099+JakobJingleheimer@users.noreply.github.com> PR-URL: https://github.com/nodejs/node/pull/49736 Reviewed-By: Antoine du Hamel Reviewed-By: Geoffrey Booth ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/49736 Reviewed-By: Antoine du Hamel Reviewed-By: Geoffrey Booth -------------------------------------------------------------------------------- ⚠ Commits were pushed since the last approving review: ⚠ - test: add case for invalid posix host ⚠ - fixup!: de-lint ℹ This PR was created on Wed, 20 Sep 2023 15:08:30 GMT ✔ Approvals: 2 ✔ - Antoine du Hamel (@aduh95) (TSC): https://github.com/nodejs/node/pull/49736#pullrequestreview-1637644110 ✔ - Geoffrey Booth (@GeoffreyBooth) (TSC): https://github.com/nodejs/node/pull/49736#pullrequestreview-1638329347 ✘ Last GitHub CI failed ℹ Last Full PR CI on 2023-09-22T18:42:45Z: https://ci.nodejs.org/job/node-test-pull-request/54154/ - Querying data for job/node-test-pull-request/54154/ ✔ Last Jenkins CI successful -------------------------------------------------------------------------------- ✔ Aborted `git node land` session in /home/runner/work/node/node/.ncuhttps://github.com/nodejs/node/actions/runs/6278312662 |
Landed in 645b788 |
PR-URL: #49736 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
PR-URL: nodejs#49736 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
PR-URL: nodejs#49736 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
PR-URL: nodejs/node#49736 Backport-PR-URL: nodejs/node#50669 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
PR-URL: nodejs/node#49736 Backport-PR-URL: nodejs/node#50669 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
New output:
fixes #49571