`wrangler d1 migrations list --remote` ignores `account_id` from the config file

Closed Beginner friendly
#16,292 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@idhanth is already working on this.

Since Oct 15, 2026.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
75/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
typescript
Domain
cli, database

Research direction

The bug is in the --remote branch of the d1 migrations list handler in packages/wrangler/src/d1/migrations/list.ts, around lines 53-55, where requireAuth({}) is called with an empty config. Compare it with the migrations apply handler, which already passes the loaded config and works with account_id set. To check the fix, run the list command with --remote in a non-interactive shell on a login with two accounts, using a config that sets account_id. Done means the command selects the configured account without prompting or erroring.

Written by the indexing model from the issue text.

Description

bug package:wrangler product:d1
What versions & operating system are you using?

wrangler 4.151.0 (also 4.134.0), Node 22, macOS 15 (Darwin 24.6.0, arm64)

Please provide a link to a minimal reproduction

No repo needed. Any project whose wrangler.jsonc sets account_id and has a D1 binding, run by a user whose login can see more than one account:

{
  "name": "example",
  "account_id": "<account A>",
  "d1_databases": [
    { "binding": "DB", "database_name": "example-db", "database_id": "<id>", "migrations_dir": "migrations" }
  ]
}
wrangler d1 migrations list example-db --remote   # in a non-interactive shell
Describe the Bug

wrangler d1 migrations list --remote ignores account_id from the config file. With more than one account on the login, it fails in a non-interactive shell (or prompts in an interactive one) even though the config names the account.

The handler authenticates with an empty config instead of the loaded one:

https://github.com/cloudflare/workers-sdk/blob/4a5377fc228dd94aa5df7545c8185cdd98be733e/packages/wrangler/src/d1/migrations/list.ts#L53-L55

if (remote) {
	await requireAuth({});
}

getActiveAccountId() only reads config.account_id, so passing {} means the account from wrangler.jsonc is never considered. wrangler d1 migrations apply --remote on the same project works, as do other commands that pass config. Passing config here (await requireAuth(config);) should fix it.

Expected: the command uses account_id from the config, as apply does.
Workaround: set CLOUDFLARE_ACCOUNT_ID.

Please provide any relevant error logs
✘ [ERROR] More than one account available but unable to select one in non-interactive mode.

  Please set the appropriate `account_id` in your Wrangler configuration file or assign it to the `CLOUDFLARE_ACCOUNT_ID` environment variable.
  Available accounts are (`<name>`: `<account_id>`):
    `<account A>`: `<id>`
    `<account B>`: `<id>`
Dominant language
TypeScript
Stars
4.7k
Forks
1.6k
Avg merge
1d 17h
Merged PRs (30d)
255

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from cloudflare/workers-sdk

All issues in cloudflare/workers-sdk

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.