From 32d9bafcc4258002184b73a42c97624dcb4b9798 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 5 Jun 2026 02:44:36 +0000 Subject: [PATCH 1/5] Initial plan From 79129bc3e16fc5170b667b005ff256111e134b17 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 5 Jun 2026 02:56:43 +0000 Subject: [PATCH 2/5] Make targetless add_comment wildcard non-fatal Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- actions/setup/js/add_comment.cjs | 9 +++++++++ actions/setup/js/add_comment.test.cjs | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/actions/setup/js/add_comment.cjs b/actions/setup/js/add_comment.cjs index fa7ec5d7521..8043c343693 100644 --- a/actions/setup/js/add_comment.cjs +++ b/actions/setup/js/add_comment.cjs @@ -504,6 +504,15 @@ async function main(config = {}) { if (!targetResult.success) { if (targetResult.shouldFail) { + const missingWildcardTarget = commentTarget === "*" && targetResult.error?.startsWith('Target is "*" but no '); + if (missingWildcardTarget) { + core.warning(targetResult.error); + return { + success: false, + skipped: true, + error: targetResult.error, + }; + } core.warning(targetResult.error); return { success: false, diff --git a/actions/setup/js/add_comment.test.cjs b/actions/setup/js/add_comment.test.cjs index c09422d47fc..5cdbb6ab894 100644 --- a/actions/setup/js/add_comment.test.cjs +++ b/actions/setup/js/add_comment.test.cjs @@ -222,7 +222,7 @@ describe("add_comment", () => { expect(result.itemNumber).toBe(28912); }); - it("should fail when target is '*' but no item_number provided", async () => { + it("should skip (not fail) when target is '*' but no item_number provided", async () => { const addCommentScript = fs.readFileSync(path.join(__dirname, "add_comment.cjs"), "utf8"); const handler = await eval(`(async () => { ${addCommentScript}; return await main({ target: '*' }); })()`); @@ -235,6 +235,7 @@ describe("add_comment", () => { const result = await handler(message, {}); expect(result.success).toBe(false); + expect(result.skipped).toBe(true); expect(result.error).toMatch(/no.*item_number/i); }); From 59681e40ede0cdacacd007aa36e7a8f952270cd9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 5 Jun 2026 02:58:58 +0000 Subject: [PATCH 3/5] Harden wildcard add_comment skip detection Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- actions/setup/js/add_comment.cjs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/actions/setup/js/add_comment.cjs b/actions/setup/js/add_comment.cjs index 8043c343693..c02c3cf1979 100644 --- a/actions/setup/js/add_comment.cjs +++ b/actions/setup/js/add_comment.cjs @@ -504,7 +504,8 @@ async function main(config = {}) { if (!targetResult.success) { if (targetResult.shouldFail) { - const missingWildcardTarget = commentTarget === "*" && targetResult.error?.startsWith('Target is "*" but no '); + const hasExplicitWildcardTargetField = message.item_number != null || message.issue_number != null || message.pull_request_number != null || message.pr_number != null || message.pr != null || message.pull_number != null; + const missingWildcardTarget = commentTarget === "*" && !hasExplicitWildcardTargetField; if (missingWildcardTarget) { core.warning(targetResult.error); return { From 8ba52731cbf9a78dac5f2bcbb131f3793f2b8604 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 5 Jun 2026 03:00:59 +0000 Subject: [PATCH 4/5] Refine add_comment wildcard target skip handling Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- actions/setup/js/add_comment.cjs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/actions/setup/js/add_comment.cjs b/actions/setup/js/add_comment.cjs index c02c3cf1979..12ce16c1553 100644 --- a/actions/setup/js/add_comment.cjs +++ b/actions/setup/js/add_comment.cjs @@ -30,6 +30,7 @@ const { resolveInvocationContext } = require("./invocation_context_helpers.cjs") /** @type {string} Safe output type handled by this module */ const HANDLER_TYPE = "add_comment"; +const WILDCARD_TARGET_FIELDS = ["item_number", "issue_number", "pull_request_number", "pr_number", "pr", "pull_number"]; /** * Deduplicate an array of strings using case-insensitive comparison, preserving original casing and order. @@ -504,17 +505,16 @@ async function main(config = {}) { if (!targetResult.success) { if (targetResult.shouldFail) { - const hasExplicitWildcardTargetField = message.item_number != null || message.issue_number != null || message.pull_request_number != null || message.pr_number != null || message.pr != null || message.pull_number != null; + const hasExplicitWildcardTargetField = WILDCARD_TARGET_FIELDS.some(field => message[field] != null); const missingWildcardTarget = commentTarget === "*" && !hasExplicitWildcardTargetField; + core.warning(targetResult.error); if (missingWildcardTarget) { - core.warning(targetResult.error); return { success: false, skipped: true, error: targetResult.error, }; } - core.warning(targetResult.error); return { success: false, error: targetResult.error, From 07064c4fc6ce035cad0c7f2905df5e1674fa7898 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 5 Jun 2026 03:57:15 +0000 Subject: [PATCH 5/5] Address review feedback for add_comment wildcard handling Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- actions/setup/js/add_comment.cjs | 5 ++++- actions/setup/js/add_comment.test.cjs | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/actions/setup/js/add_comment.cjs b/actions/setup/js/add_comment.cjs index 12ce16c1553..af4d1ad15a0 100644 --- a/actions/setup/js/add_comment.cjs +++ b/actions/setup/js/add_comment.cjs @@ -30,6 +30,8 @@ const { resolveInvocationContext } = require("./invocation_context_helpers.cjs") /** @type {string} Safe output type handled by this module */ const HANDLER_TYPE = "add_comment"; +// Keep the full list of accepted explicit wildcard target fields (including aliases +// pre-handled by resolveSafeOutputIssueTarget) to preserve a defensive boundary check. const WILDCARD_TARGET_FIELDS = ["item_number", "issue_number", "pull_request_number", "pr_number", "pr", "pull_number"]; /** @@ -507,14 +509,15 @@ async function main(config = {}) { if (targetResult.shouldFail) { const hasExplicitWildcardTargetField = WILDCARD_TARGET_FIELDS.some(field => message[field] != null); const missingWildcardTarget = commentTarget === "*" && !hasExplicitWildcardTargetField; - core.warning(targetResult.error); if (missingWildcardTarget) { + core.info(targetResult.error); return { success: false, skipped: true, error: targetResult.error, }; } + core.warning(targetResult.error); return { success: false, error: targetResult.error, diff --git a/actions/setup/js/add_comment.test.cjs b/actions/setup/js/add_comment.test.cjs index 5cdbb6ab894..22b4aa7419c 100644 --- a/actions/setup/js/add_comment.test.cjs +++ b/actions/setup/js/add_comment.test.cjs @@ -239,6 +239,24 @@ describe("add_comment", () => { expect(result.error).toMatch(/no.*item_number/i); }); + it("should hard-fail (not skip) when target is '*' and explicit pull_request_number is invalid", async () => { + const addCommentScript = fs.readFileSync(path.join(__dirname, "add_comment.cjs"), "utf8"); + + const handler = await eval(`(async () => { ${addCommentScript}; return await main({ target: '*' }); })()`); + + const message = { + type: "add_comment", + pull_request_number: "invalid", + body: "Test comment with invalid explicit pull_request_number", + }; + + const result = await handler(message, {}); + + expect(result.success).toBe(false); + expect(result.skipped).toBeUndefined(); + expect(result.error).toBeTruthy(); + }); + it("should use explicit item_number even with triggering target", async () => { const addCommentScript = fs.readFileSync(path.join(__dirname, "add_comment.cjs"), "utf8");