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

Log token info after authentication errors #3926

Merged
merged 3 commits into from
Oct 2, 2023
Merged

Conversation

penalosa
Copy link
Contributor

@penalosa penalosa commented Sep 11, 2023

Fixes #1197.

What this PR solves / how to test:

After the API returns an authentication error, log the token info returned by whoami(), to help the user diagnose the issue.

Associated docs issue(s)/PR(s):

  • [insert associated docs issue(s)/PR(s)]

Author has included the following, where applicable:

Reviewer is to perform the following, as applicable:

  • Checked for inclusion of relevant tests
  • Checked for inclusion of a relevant changeset
  • Checked for creation of associated docs updates
  • Manually pulled down the changes and spot-tested

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.

@penalosa penalosa requested a review from a team as a code owner September 11, 2023 15:52
@changeset-bot
Copy link

changeset-bot bot commented Sep 11, 2023

🦋 Changeset detected

Latest commit: 0500db9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
wrangler Patch

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

@github-actions
Copy link
Contributor

github-actions bot commented Sep 11, 2023

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/6248198321/npm-package-wrangler-3926

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/6248198321/npm-package-wrangler-3926

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/6248198321/npm-package-wrangler-3926 dev path/to/script.js
Additional artifacts:
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/6248198321/npm-package-cloudflare-pages-shared-3926

Note that these links will no longer work once the GitHub Actions artifact expires.


wrangler@3.8.0 includes the following runtime dependencies:

Package Constraint Resolved
miniflare 3.20230918.0 3.20230918.0
workerd 1.20230904.0 1.20230904.0
workerd --version 1.20230904.0 2023-09-04

|

Please ensure constraints are pinned, and miniflare/workerd minor versions match.

@codecov
Copy link

codecov bot commented Sep 20, 2023

Codecov Report

Merging #3926 (0500db9) into main (a986f19) will decrease coverage by 0.09%.
Report is 38 commits behind head on main.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3926      +/-   ##
==========================================
- Coverage   75.10%   75.01%   -0.09%     
==========================================
  Files         195      196       +1     
  Lines       11487    11608     +121     
  Branches     3036     3045       +9     
==========================================
+ Hits         8627     8708      +81     
- Misses       2860     2900      +40     
Files Changed Coverage Δ
packages/wrangler/src/deploy/deploy.ts 87.59% <100.00%> (+0.25%) ⬆️
packages/wrangler/src/index.ts 82.56% <100.00%> (+0.31%) ⬆️
packages/wrangler/src/user/user.ts 72.23% <100.00%> (ø)

... and 26 files with indirect coverage changes

@@ -721,6 +722,9 @@ export async function main(argv: string[]): Promise<void> {
// The workaround is to re-run the parsing with an additional `--help` flag, which will result in the correct help message being displayed.
// The `wrangler` object is "frozen"; we cannot reuse that with different args, so we must create a new CLI parser to generate the help message.
await createCLIParser([...argv, "--help"]).parse();
} else if (isAuthenticationError(e)) {
logger.log(formatMessage(e));
await whoami();
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this return or throw?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, it's thrown at the end of this function

@penalosa penalosa merged commit f585f69 into main Oct 2, 2023
@penalosa penalosa deleted the penalosa/whoami-auth branch October 2, 2023 16:15
@workers-devprod workers-devprod mentioned this pull request Oct 2, 2023
dario-piotrowicz pushed a commit that referenced this pull request Oct 2, 2023
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.

polish: On 10000/ auth errors, we should log details about the token
3 participants