From 611eac8703b4c1908cb245a1356f7dd030a22d2d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 4 Mar 2026 14:50:08 +0000 Subject: [PATCH 1/2] Initial plan From 0c5f0f401aee214d57d748f2a514fb6edf092fd5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 4 Mar 2026 14:57:19 +0000 Subject: [PATCH 2/2] fix: throw on search error in ensureAgentRunsIssue to prevent duplicate no-op issues Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- actions/setup/js/handle_noop_message.cjs | 2 +- actions/setup/js/handle_noop_message.test.cjs | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/actions/setup/js/handle_noop_message.cjs b/actions/setup/js/handle_noop_message.cjs index 34df5bebe88..71f4fc6c393 100644 --- a/actions/setup/js/handle_noop_message.cjs +++ b/actions/setup/js/handle_noop_message.cjs @@ -37,7 +37,7 @@ async function ensureAgentRunsIssue() { }; } } catch (error) { - core.warning(`Error searching for no-op runs issue: ${getErrorMessage(error)}`); + throw new Error(`Failed to search for existing no-op runs issue: ${getErrorMessage(error)}`); } // Create no-op runs issue if it doesn't exist diff --git a/actions/setup/js/handle_noop_message.test.cjs b/actions/setup/js/handle_noop_message.test.cjs index d9c95d8026d..a0dcd5c08e7 100644 --- a/actions/setup/js/handle_noop_message.test.cjs +++ b/actions/setup/js/handle_noop_message.test.cjs @@ -480,6 +480,36 @@ This issue helps you: expect(mockCore.warning).toHaveBeenCalledWith(expect.stringContaining("Could not create no-op runs issue")); }); + it("should not create issue when search throws (prevents duplicate issues)", async () => { + process.env.GH_AW_WORKFLOW_NAME = "Test Workflow"; + process.env.GH_AW_RUN_URL = "https://github.com/test-owner/test-repo/actions/runs/789"; + process.env.GH_AW_NOOP_MESSAGE = "All checks passed"; + process.env.GH_AW_AGENT_CONCLUSION = "success"; + + // Create agent output file with only noop outputs + const outputFile = path.join(tempDir, "agent_output.json"); + fs.writeFileSync( + outputFile, + JSON.stringify({ + items: [{ type: "noop", message: "All checks passed" }], + }) + ); + process.env.GH_AW_AGENT_OUTPUT = outputFile; + + // Mock search failure (e.g. transient API error) + mockGithub.rest.search.issuesAndPullRequests.mockRejectedValue(new Error("API rate limit exceeded")); + + const { main } = await import("./handle_noop_message.cjs?t=" + Date.now()); + await main(); + + // Search error should be caught and logged as a warning (via ensureAgentRunsIssue throw → main catch) + expect(mockCore.warning).toHaveBeenCalledWith(expect.stringContaining("Could not create no-op runs issue")); + // Issue must NOT be created to prevent duplicates + expect(mockGithub.rest.issues.create).not.toHaveBeenCalled(); + // Comment must NOT be posted + expect(mockGithub.rest.issues.createComment).not.toHaveBeenCalled(); + }); + it("should extract run ID from URL correctly", async () => { process.env.GH_AW_WORKFLOW_NAME = "Test"; process.env.GH_AW_RUN_URL = "https://github.com/owner/repo/actions/runs/987654321";