-
Notifications
You must be signed in to change notification settings - Fork 709
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
[wrangler] fix: throw helpful error if email validation required #4592
Conversation
🦋 Changeset detectedLatest commit: 62364fe The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
A wrangler prerelease is available for testing. You can install this latest build in your project with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/7387147635/npm-package-wrangler-4592 You can reference the automatically updated head of this PR with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/7387147635/npm-package-wrangler-4592 Or you can use npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/7387147635/npm-package-wrangler-4592 dev path/to/script.js Additional artifacts:npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/7387147635/npm-package-miniflare-4592 npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/7387147635/npm-package-cloudflare-pages-shared-4592 npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/7387147635/npm-package-create-cloudflare-4592 --no-auto-update Note that these links will no longer work once the GitHub Actions artifact expires.
| Please ensure constraints are pinned, and |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #4592 +/- ##
==========================================
- Coverage 75.53% 75.21% -0.33%
==========================================
Files 242 243 +1
Lines 12918 13031 +113
Branches 3324 3348 +24
==========================================
+ Hits 9758 9801 +43
- Misses 3160 3230 +70
|
I don't think this fully fixes #4187 As I mentioned in #4187 (comment), I think that a significant part of the issue is that wrangler asks the user various different questions regarding what subdomain they want to use, but all those questions are a bit pointless since at the end the command is still going to fail if the email is not verified So while having a more proper error message is an improvement I still think that the email should also be verified upfront before the rest of the questions. Would that be possible? Note I can't remember for sure if the subdomain gets generated.... it might or might not 😅 |
83bace9
to
332b484
Compare
await expect( | ||
runWrangler("deploy ./index") | ||
).rejects.toThrowErrorMatchingInlineSnapshot( | ||
`"Please verify your account's email address and try again."` |
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.
Should this snapshot contain the 2nd line? "Check your email for a verification link, or login to https://dash.cloudflare.com and request a new one."
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.
The additional text is added as a "note" to the error. This error snapshot matcher only considers the "message" of the error.
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.
If we care about the second line then I think we would need to catch the error and then stringify it before checking it against a snapshot.
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.
Updated the assertion to check notes
too. 👍
await expect( | ||
runWrangler("deploy ./index") | ||
).rejects.toThrowErrorMatchingInlineSnapshot( | ||
`"Please verify your account's email address and try again."` |
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.
The additional text is added as a "note" to the error. This error snapshot matcher only considers the "message" of the error.
await expect( | ||
runWrangler("deploy ./index") | ||
).rejects.toThrowErrorMatchingInlineSnapshot( | ||
`"Please verify your account's email address and try again."` |
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.
If we care about the second line then I think we would need to catch the error and then stringify it before checking it against a snapshot.
} | ||
|
||
export function maybeThrowFriendlyError(error: FetchError) { | ||
if (error.message === "workers.api.error.email_verification_required") { |
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.
Is the idea that this helper will be expanded to handle converting other API errors into helpful errors?
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.
Yep, exactly. Seemed likely there are more errors that could be friendlier.
Sadly, I think this is not really possible without changes to the backend that Wrangler talks to. The order of requests is that we only get the email-verification error when we deploy to the subdomain, but we need to register the subdomain before we can deploy to it. So we need to ask the questions of the user before we can find out that they haven't validated their email. I propose that we go ahead with this fix for now and decide whether we need to go further and change the flow somehow. |
332b484
to
62364fe
Compare
Fixes #4187.
What this PR solves / how to test:
Previously, Wrangler would display the raw API error message and code if email validation was required during
wrangler deploy
. This change ensures a helpful error message is displayed instead, prompting users to check their emails or visit the dashboard for a verification link. To test this, try runwrangler deploy
using aworkers.dev
subdomain on an account without a verified email. (I assume you've got one of those lying around! 😛)Author has addressed the following:
Note for PR author:
We want to celebrate and highlight awesome PR review! If you think this PR received a particularly high-caliber review, please assign it the label
highlight pr review
so future reviewers can take inspiration and learn from it.