Skip to content

/memberships returns status: 400 (code: 9106) — how should wrangler react? #13656

Description

@irvinebroque

What versions & operating system are you using?

wrangler 4.84.1
macos latest

Please provide a link to a minimal reproduction

see below

Describe the Bug

I see this and think something expired / invalid about my session:

➜ npx wrangler d1 list

 ⛅️ wrangler 4.84.1
───────────────────

✘ [ERROR] A request to the Cloudflare API (/memberships) failed.

  Authentication failed (status: 400) [code: 9106]

  If you think this is a bug, please open an issue at:
  https://github.com/cloudflare/workers-sdk/issues/new/choose

Here's the 4xx error:

{
  "code": 9106,
  "message": "Missing X-Auth-Key, X-Auth-Email or Authorization headers"
}

Then I run npx wrangler login and only then realize that wrangler is using and API token I set in my env:

 ⛅️ wrangler 4.84.1
───────────────────
✘ [ERROR] You are logged in with an API Token. Unset the CLOUDFLARE_API_TOKEN in the environment to log in via OAuth.

I think I get why this happens (because API tokens don't currently support FGA, which I have enabled on my account? slash - work that we are in progress on for the Workers API)

But thinking more broadly about how we handle 4xx errors — should we handle more gracefully?

  • suggest that the user npx wrangler logout / npx wrangler login?
  • expose earlier that an API token is being used by wrangler? and where that is coming from?
  • attempt this for them?
  • something else?

Thinking broadly about — how do we help humans and agents figure out what to do here, because won't be only time when there is 4xx

Please provide any relevant error logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    No fields configured for Bug.

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions