-
Notifications
You must be signed in to change notification settings - Fork 431
Keep detection in warn mode on parser/agent failures so non-reviewable safe outputs are blocked #41547
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Keep detection in warn mode on parser/agent failures so non-reviewable safe outputs are blocked #41547
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 || ""; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
💡 Suggested clarificationWithout a comment, a future reader may wonder whether // retained for diagnostic logging only; no longer gates conclusion (see setDetectionFailure)
const detectionExecutionOutcome = process.env.DETECTION_AGENTIC_EXECUTION_OUTCOME || "";Downstream consumers can still distinguish the failure type via |
||
| 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"); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 () => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [/tdd] The updated test covers warn mode + execution failure → 💡 Suggested test to addit("should fail when detection execution failed in error mode", async () => {
process.env.GH_AW_DETECTION_CONTINUE_ON_ERROR = "false";
process.env.DETECTION_AGENTIC_EXECUTION_OUTCOME = "failure";
mockExistsSync.mockReturnValue(false);
await mod.main();
expect(mockCore.setOutput).toHaveBeenCalledWith("conclusion", "failure");
expect(mockCore.setOutput).toHaveBeenCalledWith("success", "false");
expect(mockCore.setOutput).toHaveBeenCalledWith("reason", "agent_failure");
expect(mockCore.exportVariable).toHaveBeenCalledWith("GH_AW_DETECTION_CONCLUSION", "failure");
expect(mockCore.setFailed).toHaveBeenCalledWith(expect.stringContaining("Detection log file not found"));
});This pins that |
||
| 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 | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.