From bd7f2a29d624f123dddb9ca1ef49122cf7873e54 Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 2 Feb 2026 16:27:54 -0800 Subject: [PATCH] error cline if someone piped in empty text (#9038) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Max Paulus 🥪 --- cli/src/index.ts | 6 ++++++ cli/src/utils/piped.ts | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/cli/src/index.ts b/cli/src/index.ts index 5525755514..6dcf12edcc 100644 --- a/cli/src/index.ts +++ b/cli/src/index.ts @@ -775,6 +775,12 @@ program // Always check for piped stdin content const stdinInput = await readStdinIfPiped() + // Error if stdin was piped but empty (e.g., `echo "" | cline`) + if (stdinInput === "") { + printWarning("Empty input received from stdin. Please provide content to process.") + exit(1) + } + // If no prompt argument, check if input is piped via stdin let effectivePrompt = prompt if (stdinInput) { diff --git a/cli/src/utils/piped.ts b/cli/src/utils/piped.ts index f03adcecaa..c046a71d1d 100644 --- a/cli/src/utils/piped.ts +++ b/cli/src/utils/piped.ts @@ -40,7 +40,10 @@ export async function readStdinIfPiped(): Promise { process.stdin.on("end", () => { clearTimeout(timeout) - resolve(data.trim() || null) + // Return empty string (not null) when stdin was piped but empty + // This allows callers to distinguish between "no piped input" (null) + // and "empty piped input" ("") for proper error handling + resolve(data.trim()) }) process.stdin.on("error", () => {