From 27f5c1350096b725423b5cb7c93274d63d4017e8 Mon Sep 17 00:00:00 2001 From: Edmund Hung Date: Mon, 20 Jan 2025 14:33:33 +0000 Subject: [PATCH 1/3] fix(wrangler): improve multi account error message in non-interactive mode --- packages/wrangler/src/user/user.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/wrangler/src/user/user.ts b/packages/wrangler/src/user/user.ts index 44921f1480..89b1e082f5 100644 --- a/packages/wrangler/src/user/user.ts +++ b/packages/wrangler/src/user/user.ts @@ -1204,7 +1204,7 @@ export async function getAccountId(): Promise { if (e instanceof NoDefaultValueProvided) { throw new UserError( `More than one account available but unable to select one in non-interactive mode. -Please set the appropriate \`account_id\` in your ${configFileName(undefined)} file. +Please set the appropriate \`account_id\` in your ${configFileName(undefined)} file or assign it to the \`CLOUDFLARE_ACCOUNT_ID\` environment variable. Available accounts are (\`\`: \`\`): ${accounts .map((account) => ` \`${account.name}\`: \`${account.id}\``) From 852d6fbfc0a5cfe66f2fcf7ac06adeca749c787f Mon Sep 17 00:00:00 2001 From: Edmund Hung Date: Mon, 20 Jan 2025 15:20:20 +0000 Subject: [PATCH 2/3] chore(wrangler): udpate snapshots --- packages/wrangler/src/__tests__/deploy.test.ts | 2 +- packages/wrangler/src/__tests__/kv.test.ts | 6 +++--- packages/wrangler/src/__tests__/pages/secret.test.ts | 2 +- packages/wrangler/src/__tests__/secret.test.ts | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/wrangler/src/__tests__/deploy.test.ts b/packages/wrangler/src/__tests__/deploy.test.ts index eea34c2388..5c287c9cc6 100644 --- a/packages/wrangler/src/__tests__/deploy.test.ts +++ b/packages/wrangler/src/__tests__/deploy.test.ts @@ -619,7 +619,7 @@ describe("deploy", () => { await expect(runWrangler("deploy index.js")).rejects .toMatchInlineSnapshot(` [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. + Please set the appropriate \`account_id\` in your Wrangler configuration file or assign it to the \`CLOUDFLARE_ACCOUNT_ID\` environment variable. Available accounts are (\`\`: \`\`): \`enterprise\`: \`1701\` \`enterprise-nx\`: \`nx01\`] diff --git a/packages/wrangler/src/__tests__/kv.test.ts b/packages/wrangler/src/__tests__/kv.test.ts index 3ffe1f59f5..2e01d419b6 100644 --- a/packages/wrangler/src/__tests__/kv.test.ts +++ b/packages/wrangler/src/__tests__/kv.test.ts @@ -1275,7 +1275,7 @@ describe("wrangler", () => { await expect(runWrangler("kv key get key --namespace-id=xxxx")) .rejects.toThrowErrorMatchingInlineSnapshot(` [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. + Please set the appropriate \`account_id\` in your Wrangler configuration file or assign it to the \`CLOUDFLARE_ACCOUNT_ID\` environment variable. Available accounts are (\`\`: \`\`): \`one\`: \`1\` \`two\`: \`2\`] @@ -1291,7 +1291,7 @@ describe("wrangler", () => { await expect(runWrangler("kv key get key --namespace-id=xxxx")) .rejects.toThrowErrorMatchingInlineSnapshot(` [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. + Please set the appropriate \`account_id\` in your Wrangler configuration file or assign it to the \`CLOUDFLARE_ACCOUNT_ID\` environment variable. Available accounts are (\`\`: \`\`): \`one\`: \`1\` \`two\`: \`2\`] @@ -1332,7 +1332,7 @@ describe("wrangler", () => { await expect(runWrangler("kv key get key --namespace-id=xxxx")) .rejects.toThrowErrorMatchingInlineSnapshot(` [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. + Please set the appropriate \`account_id\` in your Wrangler configuration file or assign it to the \`CLOUDFLARE_ACCOUNT_ID\` environment variable. Available accounts are (\`\`: \`\`): \`one\`: \`1\` \`two\`: \`2\`] diff --git a/packages/wrangler/src/__tests__/pages/secret.test.ts b/packages/wrangler/src/__tests__/pages/secret.test.ts index c6ba347b8a..d24564f48d 100644 --- a/packages/wrangler/src/__tests__/pages/secret.test.ts +++ b/packages/wrangler/src/__tests__/pages/secret.test.ts @@ -274,7 +274,7 @@ describe("wrangler pages secret", () => { runWrangler("pages secret put the-key --project some-project-name") ).rejects.toThrowErrorMatchingInlineSnapshot(` [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. + Please set the appropriate \`account_id\` in your Wrangler configuration file or assign it to the \`CLOUDFLARE_ACCOUNT_ID\` environment variable. Available accounts are (\`\`: \`\`): \`account-name-1\`: \`account-id-1\` \`account-name-2\`: \`account-id-2\` diff --git a/packages/wrangler/src/__tests__/secret.test.ts b/packages/wrangler/src/__tests__/secret.test.ts index 656d2bc747..ce40ad5c12 100644 --- a/packages/wrangler/src/__tests__/secret.test.ts +++ b/packages/wrangler/src/__tests__/secret.test.ts @@ -413,7 +413,7 @@ describe("wrangler secret", () => { await expect(runWrangler("secret put the-key --name script-name")) .rejects.toThrowErrorMatchingInlineSnapshot(` [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. + Please set the appropriate \`account_id\` in your Wrangler configuration file or assign it to the \`CLOUDFLARE_ACCOUNT_ID\` environment variable. Available accounts are (\`\`: \`\`): \`account-name-1\`: \`account-id-1\` \`account-name-2\`: \`account-id-2\` From a59864e5d086c0cbe0cdb6caa8173e5e2024585f Mon Sep 17 00:00:00 2001 From: Edmund Hung Date: Mon, 20 Jan 2025 15:21:50 +0000 Subject: [PATCH 3/3] add changeset --- .changeset/twenty-ears-rescue.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/twenty-ears-rescue.md diff --git a/.changeset/twenty-ears-rescue.md b/.changeset/twenty-ears-rescue.md new file mode 100644 index 0000000000..0c75eee6ca --- /dev/null +++ b/.changeset/twenty-ears-rescue.md @@ -0,0 +1,5 @@ +--- +"wrangler": patch +--- + +improve multi account error message in non-interactive mode