Skip to content

fix(auth): accurately report missing auth profiles (#101) - #660

Merged
petebacondarwin merged 2 commits into
cloudflare:mainfrom
TheVicky1:fix/auth-profile-errors-101
Nov 18, 2026
Merged

petebacondarwin merged 2 commits into
cloudflare:mainfrom
TheVicky1:fix/auth-profile-errors-101

Conversation

@TheVicky1

@TheVicky1 TheVicky1 commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Closes #101

Summary

When commands resolve or are given a non-existent auth profile (via --profile <name> or CLOUDFLARE_AUTH_PROFILE=<name>), cf now accurately reports that the specified profile was not found, lists available profiles, and suggests running cf auth create <name> instead of emitting a misleading "No authentication token found" error.

Changes

  • In getAuthToken(), check whether an active non-default profile exists in getProfileStore(). If not, throw MissingCredentialsError with the missing profile name and available profile list.
  • Added unit test in auth-token.test.ts asserting the missing profile error format.
  • Added patch changeset.

@TheVicky1
TheVicky1 requested a review from a team as a code owner November 17, 2026 12:45
@TheVicky1
TheVicky1 requested a review from edmundhung November 17, 2026 12:45
@github-actions

Copy link
Copy Markdown
Contributor

Hi @TheVicky1. Thanks for contributing to cf!

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 cf issue. If the proposed change fits our priorities, we’d be happy to take another look at this PR.

@github-actions github-actions Bot closed this Nov 17, 2026
@TheVicky1

Copy link
Copy Markdown
Contributor Author

Hi @petebacondarwin!

I've put together a minimal fix for #101:

  • Supports CLOUDFLARE_PROFILE alongside CLOUDFLARE_AUTH_PROFILE.
  • Accurately reports when a requested non-default profile does not exist on disk (and lists available profiles) rather than throwing a misleading "No authentication token found" error.
  • Includes unit tests in auth-token.test.ts and auth.test.ts and a patch changeset.

Could you please take a look when convenient and vouch for me or reopen the PR? Thank you!

@clanky-the-clanker

clanky-the-clanker Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

This pull request's reviews are posted as pull request reviews: see the review of 5a72173e.

@edmundhung edmundhung left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

@TheVicky1
TheVicky1 force-pushed the fix/auth-profile-errors-101 branch from bbbb54e to 5a72173 Compare November 18, 2026 06:46
@TheVicky1 TheVicky1 changed the title fix(auth): support CLOUDFLARE_PROFILE and accurately report missing auth profiles (#101) fix(auth): accurately report missing auth profiles (#101) Nov 18, 2026
@TheVicky1

Copy link
Copy Markdown
Contributor Author

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.

@petebacondarwin

Copy link
Copy Markdown
Collaborator

clanker review

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Out of date: this review is of 5a72173e; the pull request is now at 5a58e647. Someone with write access can comment clanky review (or clanker review or @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

@pkg-pr-new

pkg-pr-new Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
npm i https://pkg.pr.new/cf@660

commit: 5a58e64

@petebacondarwin
petebacondarwin added this pull request to the merge queue Nov 18, 2026
Merged via the queue into cloudflare:main with commit a3eb61e Nov 18, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants