-
Notifications
You must be signed in to change notification settings - Fork 72
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
Make any errors (invalid URLs etc) throw errors in resolution #205
Conversation
I'll create an associated test update PR later (due to dependency to #204; drafted locally). |
7ad127c
to
26d9748
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.
This looks great to me. I especially appreciate the detailed reasoning in the commit message.
I have some nits I would like to tweak in the spec wording/formatting, so when you think things are good to go I will push those and merge.
Added/updated ref impl and tests. Ready for review. |
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.
I pushed some tweaks to the spec text; please take a look. The only significant one is adding a third bullet to your note explaining the "resolving module specifiers" section.
However, reviewing this I noticed one thing that we should correct before merging. The reference implementation and the spec use rather different algorithms; there are more early returns/throws in the reference implementation, and the variable names were not updated.
I imagine the algorithms are equivalent. But we should still align these, as part of the whole idea of the reference implementation is to validate that the spec algorithms give the expected results. I'm just not sure which is better, i.e. should we align the spec with the reference implementation or the reference implementation with the spec. Do you have a preference?
spec.bs
Outdated
This makes the [=resolve a module specifier=] algorithm fail immediately, i.e. throw the error, without any further fallbacks. | ||
- Successfully resolves a specifier to a [=URL=]. This makes the [=resolve a module specifier=] algorithm immediately return that [=URL=]. | ||
- Throws an error. This makes the [=resolve a module specifier=] algorithm rethrow the error, without any further fallbacks. | ||
- Fail to resolve, without an error. In this case the algorithm moves on to the next candidate. |
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.
nit: I'm wondering better labels...
IIUC the third case corresponds to Step 1.3 of #resolve-an-imports-match, right?
"Throws an error" and "Fail to resolve" sound similarly and thus the difference between them might be unclear.
Alternatives I came up with are:
- "Throws an error" and "Continue"
- "Fail to resolve, throwing an error" and "Fail to resolve, without throwing an error"
(Step 1.3 is just handling non-matching specifier keys, which doesn't look like failing something though)
Any idea?
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.
I was thinking it it corresponds to both step 1.3 and step 2.
Hmm maybe
- Resolves the specifier to null. This terminates the resolve a module specifier algorithm with a thrown exception.
- Does not resolve the specifier. In this case the algorithm moves on to the next candidate.
?
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.
"Resolves the specifier to URL", "Resolves the specifier to null" and "Does not resolve the specifier" looked great to me in terms of symmetry, but on second thought "Resolves to null" might be confusing with "Return null" in resolve an imports match
(which is actually means "Does not resolve"), and might be a little inconsistent with resolve a module specifier
interface (which throws exceptions rather than returning null).
"Does not resolve the specifier" still looks good to me, so how about something like:
- "Resolves the specifier to URL", "Throws an error" and "Does not resolve the specifier"
- "Resolves the specifier to URL", "Resolves the specifier to an error" and "Does not resolve the specifier"
?
One point I'm aware (and I was not sure) is Step 1.4-1.5 of #resolve-an-imports-match. Pros of ref impl style:
Cons of ref impl style:
Probably I should further refactor both the spec and implementation. I will try tomorow. Or are there other diffs? |
I don't think this is super clear even from the spec style. (The note attempts to clarify it, but as seen from our above discussion, the exact correspondence between those three cases and different steps in the algorithms is not 1:1.) So, I think I lean toward the reference implementation style. |
+1 to the reference implementation style. Preparing a commit... |
Pushed. WDYT? |
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.
I pushed one more commit to make the reference implementation and spec 100% align. Let me know if it looks good and if so we can merge.
Looks good! |
Reflects WICG/import-maps#205. This CL updates tests from #205. To match the behavior with the updated spec, this CL turns non-String values into `null` entries (i.e. make whole resolution fail without further fallback), instead of ignoring such entries. Other aspects were already conformant with the updated spec (i.e. weren't matching with the spec before #205). This CL updates (test-only) import maps serialization code so that it matches with the reference implementation, i.e. dump `null` entries as `null` instead of `[]`. This CL also updates spec comments. Bug: 990561, WICG/import-maps#184 Change-Id: Ifa2d04bf20fcef5575c14d135c328730ea09c454
Reflects WICG/import-maps#205. This CL updates tests from #205. To match the behavior with the updated spec, this CL turns non-String values into `null` entries (i.e. make whole resolution fail without further fallback), instead of ignoring such entries. Other aspects were already conformant with the updated spec (i.e. weren't matching with the spec before #205). This CL updates (test-only) import maps serialization code so that it matches with the reference implementation, i.e. dump `null` entries as `null` instead of `[]`. This CL also updates spec comments. Bug: 990561, WICG/import-maps#184 Change-Id: Ifa2d04bf20fcef5575c14d135c328730ea09c454
Reflects WICG/import-maps#205. This CL updates tests from #205. To match the behavior with the updated spec, this CL turns non-String values into `null` entries (i.e. make whole resolution fail without further fallback), instead of ignoring such entries. Other aspects were already conformant with the updated spec (i.e. weren't matching with the spec before #205). This CL updates (test-only) import maps serialization code so that it matches with the reference implementation, i.e. dump `null` entries as `null` instead of `[]`. This CL also updates spec comments. Bug: 990561, WICG/import-maps#184 Change-Id: Ifa2d04bf20fcef5575c14d135c328730ea09c454 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2037012 Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org> Reviewed-by: Kouhei Ueno <kouhei@chromium.org> Cr-Commit-Position: refs/heads/master@{#740847}
Reflects WICG/import-maps#205. This CL updates tests from #205. To match the behavior with the updated spec, this CL turns non-String values into `null` entries (i.e. make whole resolution fail without further fallback), instead of ignoring such entries. Other aspects were already conformant with the updated spec (i.e. weren't matching with the spec before #205). This CL updates (test-only) import maps serialization code so that it matches with the reference implementation, i.e. dump `null` entries as `null` instead of `[]`. This CL also updates spec comments. Bug: 990561, WICG/import-maps#184 Change-Id: Ifa2d04bf20fcef5575c14d135c328730ea09c454 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2037012 Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org> Reviewed-by: Kouhei Ueno <kouhei@chromium.org> Cr-Commit-Position: refs/heads/master@{#740847}
Reflects WICG/import-maps#205. This CL updates tests from #205. To match the behavior with the updated spec, this CL turns non-String values into `null` entries (i.e. make whole resolution fail without further fallback), instead of ignoring such entries. Other aspects were already conformant with the updated spec (i.e. weren't matching with the spec before #205). This CL updates (test-only) import maps serialization code so that it matches with the reference implementation, i.e. dump `null` entries as `null` instead of `[]`. This CL also updates spec comments. Bug: 990561, WICG/import-maps#184 Change-Id: Ifa2d04bf20fcef5575c14d135c328730ea09c454 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2037012 Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org> Reviewed-by: Kouhei Ueno <kouhei@chromium.org> Cr-Commit-Position: refs/heads/master@{#740847}
…e resolution, Blink-side, a=testonly Automatic update from web-platform-tests [Import Maps] Make errors block the whole resolution, Blink-side Reflects WICG/import-maps#205. This CL updates tests from #205. To match the behavior with the updated spec, this CL turns non-String values into `null` entries (i.e. make whole resolution fail without further fallback), instead of ignoring such entries. Other aspects were already conformant with the updated spec (i.e. weren't matching with the spec before #205). This CL updates (test-only) import maps serialization code so that it matches with the reference implementation, i.e. dump `null` entries as `null` instead of `[]`. This CL also updates spec comments. Bug: 990561, WICG/import-maps#184 Change-Id: Ifa2d04bf20fcef5575c14d135c328730ea09c454 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2037012 Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org> Reviewed-by: Kouhei Ueno <kouhei@chromium.org> Cr-Commit-Position: refs/heads/master@{#740847} -- wpt-commits: 8767abfffb790e4928ac9433282928caa2357ee8 wpt-pr: 21707
…e resolution, Blink-side, a=testonly Automatic update from web-platform-tests [Import Maps] Make errors block the whole resolution, Blink-side Reflects WICG/import-maps#205. This CL updates tests from #205. To match the behavior with the updated spec, this CL turns non-String values into `null` entries (i.e. make whole resolution fail without further fallback), instead of ignoring such entries. Other aspects were already conformant with the updated spec (i.e. weren't matching with the spec before #205). This CL updates (test-only) import maps serialization code so that it matches with the reference implementation, i.e. dump `null` entries as `null` instead of `[]`. This CL also updates spec comments. Bug: 990561, WICG/import-maps#184 Change-Id: Ifa2d04bf20fcef5575c14d135c328730ea09c454 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2037012 Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org> Reviewed-by: Kouhei Ueno <kouhei@chromium.org> Cr-Commit-Position: refs/heads/master@{#740847} -- wpt-commits: 8767abfffb790e4928ac9433282928caa2357ee8 wpt-pr: 21707
…e resolution, Blink-side, a=testonly Automatic update from web-platform-tests [Import Maps] Make errors block the whole resolution, Blink-side Reflects WICG/import-maps#205. This CL updates tests from #205. To match the behavior with the updated spec, this CL turns non-String values into `null` entries (i.e. make whole resolution fail without further fallback), instead of ignoring such entries. Other aspects were already conformant with the updated spec (i.e. weren't matching with the spec before #205). This CL updates (test-only) import maps serialization code so that it matches with the reference implementation, i.e. dump `null` entries as `null` instead of `[]`. This CL also updates spec comments. Bug: 990561, WICG/import-maps#184 Change-Id: Ifa2d04bf20fcef5575c14d135c328730ea09c454 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2037012 Commit-Queue: Hiroshige Hayashizaki <hiroshigechromium.org> Reviewed-by: Kouhei Ueno <kouheichromium.org> Cr-Commit-Position: refs/heads/master{#740847} -- wpt-commits: 8767abfffb790e4928ac9433282928caa2357ee8 wpt-pr: 21707 UltraBlame original commit: e620b95565ea737f093567c22c6b8ce07e37b7dc
…e resolution, Blink-side, a=testonly Automatic update from web-platform-tests [Import Maps] Make errors block the whole resolution, Blink-side Reflects WICG/import-maps#205. This CL updates tests from #205. To match the behavior with the updated spec, this CL turns non-String values into `null` entries (i.e. make whole resolution fail without further fallback), instead of ignoring such entries. Other aspects were already conformant with the updated spec (i.e. weren't matching with the spec before #205). This CL updates (test-only) import maps serialization code so that it matches with the reference implementation, i.e. dump `null` entries as `null` instead of `[]`. This CL also updates spec comments. Bug: 990561, WICG/import-maps#184 Change-Id: Ifa2d04bf20fcef5575c14d135c328730ea09c454 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2037012 Commit-Queue: Hiroshige Hayashizaki <hiroshigechromium.org> Reviewed-by: Kouhei Ueno <kouheichromium.org> Cr-Commit-Position: refs/heads/master{#740847} -- wpt-commits: 8767abfffb790e4928ac9433282928caa2357ee8 wpt-pr: 21707 UltraBlame original commit: e620b95565ea737f093567c22c6b8ce07e37b7dc
…e resolution, Blink-side, a=testonly Automatic update from web-platform-tests [Import Maps] Make errors block the whole resolution, Blink-side Reflects WICG/import-maps#205. This CL updates tests from #205. To match the behavior with the updated spec, this CL turns non-String values into `null` entries (i.e. make whole resolution fail without further fallback), instead of ignoring such entries. Other aspects were already conformant with the updated spec (i.e. weren't matching with the spec before #205). This CL updates (test-only) import maps serialization code so that it matches with the reference implementation, i.e. dump `null` entries as `null` instead of `[]`. This CL also updates spec comments. Bug: 990561, WICG/import-maps#184 Change-Id: Ifa2d04bf20fcef5575c14d135c328730ea09c454 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2037012 Commit-Queue: Hiroshige Hayashizaki <hiroshigechromium.org> Reviewed-by: Kouhei Ueno <kouheichromium.org> Cr-Commit-Position: refs/heads/master{#740847} -- wpt-commits: 8767abfffb790e4928ac9433282928caa2357ee8 wpt-pr: 21707 UltraBlame original commit: e620b95565ea737f093567c22c6b8ce07e37b7dc
This PR all errors (found either at parsing or resolution time) throw errors at resolution.
Before this PR, errors found at parsing time, namely:
null
,[]
, etc./
and values without trailing/
were ignored, allowing fallback to next candidates at resolution time, and thus can't be used as a definitive way to block particular resolution.
After this PR, such entries are kept in specifier maps as entries with
null
value, and cause resolutions fail (without further fallback) by throwing errors.For thus purpose, this PR changes the type of values of specifier maps to
URL
ornull
.Also, before this PR, relative URL resolution failures at prefix matching in
#resolve-a-module-specifier
didn't allow fallback to less specific prefixes while allowing fallback to less specific scopes.This PR makes such errors throw errors, disallowing fallback to less specific prefixes and scopes.
This PR unifies resolution failures into one: throwing an error.
After this PR, all kind of errors throw at resolution time and definitively blocking resolution.
Fallback to less specific scopes occur only when there are no matching entries in a scope.
Fixes #184.
Preview | Diff