feat(wrangler): add warning when account_id mismatch detected on auth error#11683
feat(wrangler): add warning when account_id mismatch detected on auth error#11683
Conversation
… error When a 401 authentication error occurs, display a warning if the account_id in the Wrangler configuration does not match any of the user's authenticated accounts. This helps users identify configuration issues where they may have the wrong account ID set in their wrangler.toml file. Fixes #9358 Co-Authored-By: mkane@cloudflare.com <m@mk.gg>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
🦋 Changeset detectedLatest commit: 7c3ed78 The changes in this PR will be included in the next version bump. 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 |
|
Claude finished @ascorbic's task —— View job Changeset Review Complete
✅ All changesets look good The changeset
|
create-cloudflare
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
…error (v3 backport) Backport of #11683 to v3-maintenance branch. When a 401 authentication error occurs, display a warning if the account_id in the Wrangler configuration does not match any of the user's authenticated accounts. This helps users identify configuration issues where they may have the wrong account ID set in their wrangler.toml file. Fixes #9358 Co-Authored-By: mkane@cloudflare.com <m@mk.gg>
Move the default value assignment to the variable declaration instead of the catch block. This is a minor simplification as the full optional chaining approach doesn't work due to type constraints - ComplianceConfig doesn't include account_id, only the full Config type does. Co-Authored-By: mkane@cloudflare.com <m@mk.gg>
|
(aside) I've reviewed this and it looks good. |
|
Failed to automatically backport this PR's changes to Wrangler v3. Please manually create a PR targeting the Depending on your changes, running Notes:
|
- Update changeset to mention both wrangler.toml and wrangler.jsonc - Convert inline comment to JSDoc for printAccountIdMismatchWarning function Co-Authored-By: mkane@cloudflare.com <m@mk.gg>
Address vicb's review feedback to add JSDoc documentation. Co-Authored-By: mkane@cloudflare.com <m@mk.gg>
… error (#11683) * feat(wrangler): add warning when account_id mismatch detected on auth error When a 401 authentication error occurs, display a warning if the account_id in the Wrangler configuration does not match any of the user's authenticated accounts. This helps users identify configuration issues where they may have the wrong account ID set in their wrangler.toml file. Fixes #9358 Co-Authored-By: mkane@cloudflare.com <m@mk.gg> * refactor: simplify complianceConfig initialization Move the default value assignment to the variable declaration instead of the catch block. This is a minor simplification as the full optional chaining approach doesn't work due to type constraints - ComplianceConfig doesn't include account_id, only the full Config type does. Co-Authored-By: mkane@cloudflare.com <m@mk.gg> * chore: address review feedback - Update changeset to mention both wrangler.toml and wrangler.jsonc - Convert inline comment to JSDoc for printAccountIdMismatchWarning function Co-Authored-By: mkane@cloudflare.com <m@mk.gg> * chore: add JSDoc to whoami function Address vicb's review feedback to add JSDoc documentation. Co-Authored-By: mkane@cloudflare.com <m@mk.gg> * Minor `whoami` JSDoc tweaks --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Ben <4991309+NuroDev@users.noreply.github.com>
…error (v3 backport) (#11689) * fix(wrangler): add warning when account_id mismatch detected on auth error (v3 backport) Backport of #11683 to v3-maintenance branch. When a 401 authentication error occurs, display a warning if the account_id in the Wrangler configuration does not match any of the user's authenticated accounts. This helps users identify configuration issues where they may have the wrong account ID set in their wrangler.toml file. Fixes #9358 Co-Authored-By: mkane@cloudflare.com <m@mk.gg> * fix: capture configAccountId in middleware instead of catch block Move the config reading to the middleware callback where args is in scope, and capture configAccountId there. This fixes the TypeScript error where args was not defined in the catch block. Co-Authored-By: mkane@cloudflare.com <m@mk.gg> * style: fix formatting in whoami files Co-Authored-By: mkane@cloudflare.com <m@mk.gg> * chore: address review feedback - add JSDoc comments - Add JSDoc to whoami function - Add JSDoc to printAccountIdMismatchWarning function - Update changeset to mention wrangler.jsonc Co-Authored-By: mkane@cloudflare.com <m@mk.gg> * chore: add backticks to JSDoc parameter names Address NuroDev's review feedback to add backticks around parameter names in JSDoc comments. Co-Authored-By: mkane@cloudflare.com <m@mk.gg> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
… error (cloudflare#11683) * feat(wrangler): add warning when account_id mismatch detected on auth error When a 401 authentication error occurs, display a warning if the account_id in the Wrangler configuration does not match any of the user's authenticated accounts. This helps users identify configuration issues where they may have the wrong account ID set in their wrangler.toml file. Fixes cloudflare#9358 Co-Authored-By: mkane@cloudflare.com <m@mk.gg> * refactor: simplify complianceConfig initialization Move the default value assignment to the variable declaration instead of the catch block. This is a minor simplification as the full optional chaining approach doesn't work due to type constraints - ComplianceConfig doesn't include account_id, only the full Config type does. Co-Authored-By: mkane@cloudflare.com <m@mk.gg> * chore: address review feedback - Update changeset to mention both wrangler.toml and wrangler.jsonc - Convert inline comment to JSDoc for printAccountIdMismatchWarning function Co-Authored-By: mkane@cloudflare.com <m@mk.gg> * chore: add JSDoc to whoami function Address vicb's review feedback to add JSDoc documentation. Co-Authored-By: mkane@cloudflare.com <m@mk.gg> * Minor `whoami` JSDoc tweaks --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Ben <4991309+NuroDev@users.noreply.github.com>
Fixes #9358.
When a 401 authentication error occurs, this PR adds a warning if the
account_idin the Wrangler configuration does not match any of the user's authenticated accounts. This helps users identify configuration issues where they may have copied anaccount_idfrom another account or project.The warning is displayed after the account list in the
whoamioutput that appears on authentication errors, making it clear that the configured account ID is not accessible with the current credentials.Key changes:
printAccountIdMismatchWarningfunction inwhoami.tsthat checks if the configured account_id matches any authenticated accountshandleErrorto extractaccount_idfrom config and pass it towhoamiHuman review checklist:
Link to Devin run: https://app.devin.ai/sessions/d7fdc064c9914225b7de6694b36e0122
Devin PR requested by @ascorbic