From 5bb3554330a44fde8c21454ae017571752c6abd8 Mon Sep 17 00:00:00 2001 From: Mario Campos Date: Thu, 29 Oct 2026 10:13:06 -0500 Subject: [PATCH] Make input-validation assertions more granular --- pr-checks/post-comment.test.ts | 4 ++-- pr-checks/post-comment.ts | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pr-checks/post-comment.test.ts b/pr-checks/post-comment.test.ts index 8c1ad5d83..d82f5d249 100644 --- a/pr-checks/post-comment.test.ts +++ b/pr-checks/post-comment.test.ts @@ -64,14 +64,14 @@ describe("parseOptions", async () => { await it("rejects an empty --marker", () => { assert.throws( () => parseOptions(withFlag("--marker", "")), - /Missing required flag --marker/, + /The value for --marker cannot be empty/, ); }); await it("rejects a whitespace-only --marker", () => { assert.throws( () => parseOptions(withFlag("--marker", " \t\n")), - /Missing required flag --marker/, + /The value for --marker cannot be empty/, ); }); }); diff --git a/pr-checks/post-comment.ts b/pr-checks/post-comment.ts index 8c9703357..20dad0cf0 100644 --- a/pr-checks/post-comment.ts +++ b/pr-checks/post-comment.ts @@ -46,12 +46,16 @@ export function parseOptions(argv?: string[]): Options { strict: true, }); - assert(values.marker?.trim(), "Missing required flag --marker."); + assert(values.marker !== undefined, "Missing required flag --marker."); + assert( + values.marker.trim() !== "", + "The value for --marker cannot be empty.", + ); const [owner, repo] = values.repository!.split("/"); return { body: values.body!, - marker: values.marker!, + marker: values.marker, issueId: Number(values["issue-id"]), repository: { owner, repo }, };