You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Added a check in non-TTY environments for `account_id`, `CLOUDFLARE_ACCOUNT_ID` and `CLOUDFLARE_API_TOKEN`. If `account_id` exists in `wrangler.toml`
then `CLOUDFLARE_ACCOUNT_ID` is not needed in non-TTY scope. The `CLOUDFLARE_API_TOKEN` is necessary in non-TTY scope and will always error if missing.
resolves#827
"[31mX [41;31m[[41;97mERROR[41;31m][0m [1mMissing 'CLOUDFLARE_API_TOKEN' from non-TTY environment, please see docs for more info: TBD[0m
236
+
"[31mX [41;31m[[41;97mERROR[41;31m][0m [1mIn a non-interactive environment, it's necessary to set a CLOUDFLARE_API_TOKEN environment variable for wrangler to work.
237
+
Please go to https://developers.cloudflare.com/api/tokens/create/ for instructions on how to create an api token, and assign its value to CLOUDFLARE_API_TOKEN.[0m
237
238
239
+
"
240
+
`);
241
+
});
242
+
it("should throw error with no account ID provided and no members retrieved",async()=>{
243
+
setIsTTY(false);
244
+
writeWranglerToml({
245
+
account_id: undefined,
246
+
});
247
+
process.env={
248
+
CLOUDFLARE_API_TOKEN: "picard",
249
+
CLOUDFLARE_ACCOUNT_ID: undefined,
250
+
};
251
+
writeWorkerSource();
252
+
mockSubDomainRequest();
253
+
mockUploadWorkerRequest();
254
+
mockOAuthServerCallback();
255
+
mockGetMemberships({
256
+
success: false,
257
+
result: [],
258
+
});
238
259
239
-
[31mX [41;31m[[41;97mERROR[41;31m][0m [1mDid not login, quitting...[0m
"[31mX [41;31m[[41;97mERROR[41;31m][0m [1mFailed to automatically retrieve account IDs for the logged in user.
264
+
In a non-interactive environment, it is mandatory to specify an account ID, either by assigning its value to CLOUDFLARE_ACCOUNT_ID, or as \`account_id\` in your \`wrangler.toml\` file.[0m
runWrangler("secret put the-key --name script-name")
182
-
).rejects.toThrowErrorMatchingInlineSnapshot(
183
-
`"No account id found, quitting..."`
184
-
);
178
+
awaitexpect(runWrangler("secret put the-key --name script-name"))
179
+
.rejects.toThrowErrorMatchingInlineSnapshot(`
180
+
"Failed to automatically retrieve account IDs for the logged in user.
181
+
In a non-interactive environment, it is mandatory to specify an account ID, either by assigning its value to CLOUDFLARE_ACCOUNT_ID, or as \`account_id\` in your \`wrangler.toml\` file."
182
+
`);
185
183
});
186
184
187
185
it("should use the account from wrangler.toml",async()=>{
"Missing 'CLOUDFLARE_API_TOKEN' from non-TTY environment, please see docs for more info: TBD"
421
+
thrownewError(
422
+
"In a non-interactive environment, it's necessary to set a CLOUDFLARE_API_TOKEN environment variable for wrangler to work. Please go to https://developers.cloudflare.com/api/tokens/create/ for instructions on how to create an api token, and assign its value to CLOUDFLARE_API_TOKEN."
@@ -1142,6 +1140,11 @@ export async function getAccountId(
1142
1140
.join("\n")
1143
1141
);
1144
1142
}
1143
+
}else{
1144
+
if(!isInteractive)
1145
+
thrownewError(
1146
+
`Failed to automatically retrieve account IDs for the logged in user. In a non-interactive environment, it is mandatory to specify an account ID, either by assigning its value to CLOUDFLARE_ACCOUNT_ID, or as \`account_id\` in your \`wrangler.toml\` file.`
0 commit comments