From 2bc4144f6a4f0339b2f0d647682a7015c6045ad1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 25 Jun 2026 21:35:42 +0000 Subject: [PATCH] Adjust detection parse outcome for warn mode Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- actions/setup/js/parse_threat_detection_results.cjs | 4 +--- actions/setup/js/parse_threat_detection_results.test.cjs | 8 ++++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/actions/setup/js/parse_threat_detection_results.cjs b/actions/setup/js/parse_threat_detection_results.cjs index 747f6404bad..d4179f8a744 100644 --- a/actions/setup/js/parse_threat_detection_results.cjs +++ b/actions/setup/js/parse_threat_detection_results.cjs @@ -453,7 +453,6 @@ async function main() { const runDetection = process.env.RUN_DETECTION; const continueOnError = process.env.GH_AW_DETECTION_CONTINUE_ON_ERROR !== "false"; const detectionExecutionOutcome = process.env.DETECTION_AGENTIC_EXECUTION_OUTCOME || ""; - const detectionExecutionFailed = detectionExecutionOutcome === "failure"; const isWarnMode = continueOnError; /** @@ -464,10 +463,9 @@ async function main() { * @param {string} message - Human-readable error message */ function setDetectionFailure(reason, message) { - const mustFail = detectionExecutionFailed && (reason === "agent_failure" || reason === "parse_error"); core.setOutput("reason", reason); core.exportVariable("GH_AW_DETECTION_REASON", reason); - if (isWarnMode && !mustFail) { + if (isWarnMode) { core.warning(`⚠️ ${message}`); core.setOutput("conclusion", "warning"); core.exportVariable("GH_AW_DETECTION_CONCLUSION", "warning"); diff --git a/actions/setup/js/parse_threat_detection_results.test.cjs b/actions/setup/js/parse_threat_detection_results.test.cjs index 5dda42a2fcd..6986b7d1591 100644 --- a/actions/setup/js/parse_threat_detection_results.test.cjs +++ b/actions/setup/js/parse_threat_detection_results.test.cjs @@ -830,18 +830,18 @@ describe("main", () => { expect(mockCore.setFailed).toHaveBeenCalledWith(expect.stringContaining("Detection log file not found")); }); - it("should fail when detection execution failed even in warn mode", async () => { + it("should warn when detection execution failed in warn mode", async () => { process.env.DETECTION_AGENTIC_EXECUTION_OUTCOME = "failure"; mockExistsSync.mockReturnValue(false); await mod.main(); - expect(mockCore.setOutput).toHaveBeenCalledWith("conclusion", "failure"); + expect(mockCore.setOutput).toHaveBeenCalledWith("conclusion", "warning"); expect(mockCore.setOutput).toHaveBeenCalledWith("success", "false"); expect(mockCore.setOutput).toHaveBeenCalledWith("reason", "agent_failure"); - expect(mockCore.exportVariable).toHaveBeenCalledWith("GH_AW_DETECTION_CONCLUSION", "failure"); + expect(mockCore.exportVariable).toHaveBeenCalledWith("GH_AW_DETECTION_CONCLUSION", "warning"); expect(mockCore.exportVariable).toHaveBeenCalledWith("GH_AW_DETECTION_REASON", "agent_failure"); - expect(mockCore.setFailed).toHaveBeenCalledWith(expect.stringContaining("Detection log file not found")); + expect(mockCore.setFailed).not.toHaveBeenCalled(); }); // Note: The following tests are skipped because mocking fs for CJS modules