Skip to content

Commit 9077a67

Browse files
authored
fix(wrangler): improve multi account error message in non-interactive mode (#7828)
1 parent 0f88d85 commit 9077a67

File tree

6 files changed

+12
-7
lines changed

6 files changed

+12
-7
lines changed

.changeset/twenty-ears-rescue.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"wrangler": patch
3+
---
4+
5+
improve multi account error message in non-interactive mode

packages/wrangler/src/__tests__/deploy.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ describe("deploy", () => {
619619
await expect(runWrangler("deploy index.js")).rejects
620620
.toMatchInlineSnapshot(`
621621
[Error: More than one account available but unable to select one in non-interactive mode.
622-
Please set the appropriate \`account_id\` in your Wrangler configuration file.
622+
Please set the appropriate \`account_id\` in your Wrangler configuration file or assign it to the \`CLOUDFLARE_ACCOUNT_ID\` environment variable.
623623
Available accounts are (\`<name>\`: \`<account_id>\`):
624624
\`enterprise\`: \`1701\`
625625
\`enterprise-nx\`: \`nx01\`]

packages/wrangler/src/__tests__/kv.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,7 +1275,7 @@ describe("wrangler", () => {
12751275
await expect(runWrangler("kv key get key --namespace-id=xxxx"))
12761276
.rejects.toThrowErrorMatchingInlineSnapshot(`
12771277
[Error: More than one account available but unable to select one in non-interactive mode.
1278-
Please set the appropriate \`account_id\` in your Wrangler configuration file.
1278+
Please set the appropriate \`account_id\` in your Wrangler configuration file or assign it to the \`CLOUDFLARE_ACCOUNT_ID\` environment variable.
12791279
Available accounts are (\`<name>\`: \`<account_id>\`):
12801280
\`one\`: \`1\`
12811281
\`two\`: \`2\`]
@@ -1291,7 +1291,7 @@ describe("wrangler", () => {
12911291
await expect(runWrangler("kv key get key --namespace-id=xxxx"))
12921292
.rejects.toThrowErrorMatchingInlineSnapshot(`
12931293
[Error: More than one account available but unable to select one in non-interactive mode.
1294-
Please set the appropriate \`account_id\` in your Wrangler configuration file.
1294+
Please set the appropriate \`account_id\` in your Wrangler configuration file or assign it to the \`CLOUDFLARE_ACCOUNT_ID\` environment variable.
12951295
Available accounts are (\`<name>\`: \`<account_id>\`):
12961296
\`one\`: \`1\`
12971297
\`two\`: \`2\`]
@@ -1332,7 +1332,7 @@ describe("wrangler", () => {
13321332
await expect(runWrangler("kv key get key --namespace-id=xxxx"))
13331333
.rejects.toThrowErrorMatchingInlineSnapshot(`
13341334
[Error: More than one account available but unable to select one in non-interactive mode.
1335-
Please set the appropriate \`account_id\` in your Wrangler configuration file.
1335+
Please set the appropriate \`account_id\` in your Wrangler configuration file or assign it to the \`CLOUDFLARE_ACCOUNT_ID\` environment variable.
13361336
Available accounts are (\`<name>\`: \`<account_id>\`):
13371337
\`one\`: \`1\`
13381338
\`two\`: \`2\`]

packages/wrangler/src/__tests__/pages/secret.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ describe("wrangler pages secret", () => {
274274
runWrangler("pages secret put the-key --project some-project-name")
275275
).rejects.toThrowErrorMatchingInlineSnapshot(`
276276
[Error: More than one account available but unable to select one in non-interactive mode.
277-
Please set the appropriate \`account_id\` in your Wrangler configuration file.
277+
Please set the appropriate \`account_id\` in your Wrangler configuration file or assign it to the \`CLOUDFLARE_ACCOUNT_ID\` environment variable.
278278
Available accounts are (\`<name>\`: \`<account_id>\`):
279279
\`account-name-1\`: \`account-id-1\`
280280
\`account-name-2\`: \`account-id-2\`

packages/wrangler/src/__tests__/secret.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ describe("wrangler secret", () => {
413413
await expect(runWrangler("secret put the-key --name script-name"))
414414
.rejects.toThrowErrorMatchingInlineSnapshot(`
415415
[Error: More than one account available but unable to select one in non-interactive mode.
416-
Please set the appropriate \`account_id\` in your Wrangler configuration file.
416+
Please set the appropriate \`account_id\` in your Wrangler configuration file or assign it to the \`CLOUDFLARE_ACCOUNT_ID\` environment variable.
417417
Available accounts are (\`<name>\`: \`<account_id>\`):
418418
\`account-name-1\`: \`account-id-1\`
419419
\`account-name-2\`: \`account-id-2\`

packages/wrangler/src/user/user.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,7 @@ export async function getAccountId(): Promise<string> {
12041204
if (e instanceof NoDefaultValueProvided) {
12051205
throw new UserError(
12061206
`More than one account available but unable to select one in non-interactive mode.
1207-
Please set the appropriate \`account_id\` in your ${configFileName(undefined)} file.
1207+
Please set the appropriate \`account_id\` in your ${configFileName(undefined)} file or assign it to the \`CLOUDFLARE_ACCOUNT_ID\` environment variable.
12081208
Available accounts are (\`<name>\`: \`<account_id>\`):
12091209
${accounts
12101210
.map((account) => ` \`${account.name}\`: \`${account.id}\``)

0 commit comments

Comments
 (0)