Repository navigation
fix(auth): accurately report missing auth profiles (#101) - #660
Conversation
|
Hi @TheVicky1. Thanks for contributing to During the release candidate phase, we’re being very intentional about the changes we accept so that we can prioritise stability for GA. We’re limiting pull requests to contributions coordinated with the team in advance, so this PR has been automatically closed. We’d still love to hear about your use case, so please make sure it’s captured in a |
|
Hi @petebacondarwin! I've put together a minimal fix for #101:
Could you please take a look when convenient and vouch for me or reopen the PR? Thank you! |
|
This pull request's reviews are posted as pull request reviews: see the review of |
edmundhung
left a comment
There was a problem hiding this comment.
I don't think we should add CLOUDFLARE_PROFILE. We don't support or document it anywhere else, and CLOUDFLARE_AUTH_PROFILE already selects the profile from the environment. Can you please drop the CLOUDFLARE_PROFILE support and keep this PR to the missing-profile error.
bbbb54e to
5a72173
Compare
|
Thanks for the feedback @edmundhung! I've dropped CLOUDFLARE_PROFILE and kept this PR strictly focused on the missing-profile error. The commit, changeset, and PR title have been updated accordingly. |
|
clanker review |
There was a problem hiding this comment.
⚠️ Out of date: this review is of5a72173e; the pull request is now at5a58e647. Someone with write access can commentclanky review(orclanker reviewor@clanky-the-clanker review) to review the new commits.
💬 Approved with comments — The fix is correct and narrowly scoped; the only note is an optional suggestion to test two more branches of the new check.
Findings: 1 suggestion (1 is an inline comment on the diff)
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
📋 Code Quality: 💬 1 suggestion
The fix is correct and placed sensibly; two branches of the new check have no test.
Recommendation: 💬 Optional Nits
- [SUGGESTION] The new test covers only the "profile not found, one profile available" case; the empty-list and existing-profile branches have no test. (
packages/cli/src/__tests__/lib/auth-token.test.ts:68)
View full review
The missing-profile check runs only after every credential source has failed, so a valid credential is never hidden by it. Its use of the profile store matches commands/auth/profiles.ts.
Two branches of packages/cli/src/lib/auth-token.ts:48-59 have no test:
- An empty profile list, where the message must not contain
(available: ). - A non-default profile that exists, which should still end in the generic "No authentication token found" error.
✅ All other checks passed
📝 Documentation: ✅ LGTM
The changeset uses "cf": patch as a fix should and describes the change accurately.
Reviewed commit: 5a72173e
commit: |
Closes #101
Summary
When commands resolve or are given a non-existent auth profile (via
--profile <name>orCLOUDFLARE_AUTH_PROFILE=<name>),cfnow accurately reports that the specified profile was not found, lists available profiles, and suggests runningcf auth create <name>instead of emitting a misleading "No authentication token found" error.Changes
getAuthToken(), check whether an active non-default profile exists ingetProfileStore(). If not, throwMissingCredentialsErrorwith the missing profile name and available profile list.auth-token.test.tsasserting the missing profile error format.