Skip to content

Commit c409318

Browse files
authored
Add undefined/null checks to containers list (#9024)
Provide helpful error message when user lists containers but has none to list instead of an obscure error.
1 parent 5ce70bd commit c409318

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

.changeset/cold-aliens-learn.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+
Correctly handle 0 length responses to wrangler containers list.

packages/wrangler/src/containers/containers.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,18 @@ async function listCommandHandle(
175175
return;
176176
}
177177

178+
// If we don't get multiple applications for any reason exit
179+
if (
180+
applications === undefined ||
181+
applications === null ||
182+
applications.length === 0
183+
) {
184+
logRaw(
185+
"No containers found. See https://dash.cloudflare.com/?to=/:account/workers/containers to learn more."
186+
);
187+
return;
188+
}
189+
178190
const applicationDetails = (a: Application) => {
179191
const details = flatDetails(a);
180192
return {

0 commit comments

Comments
 (0)