From da5002f077b12da9355cd073e47f3b4879c9298d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 17 Oct 2025 19:56:23 +0000 Subject: [PATCH 1/4] Initial plan From 959fc8309fed3b6c04a5243539eefca8b95292dc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 17 Oct 2025 20:25:18 +0000 Subject: [PATCH 2/4] Fix JavaScript test failures related to agent output file reading Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- pkg/workflow/js/add_comment.test.cjs | 20 ++--- pkg/workflow/js/add_labels.test.cjs | 82 +++++++++---------- .../js/create_code_scanning_alert.test.cjs | 6 +- pkg/workflow/js/create_issue.test.cjs | 38 ++++----- .../js/create_pr_review_comment.test.cjs | 32 ++++---- pkg/workflow/js/create_pull_request.test.cjs | 10 ++- pkg/workflow/js/missing_tool.cjs | 7 ++ .../js/push_to_pull_request_branch.cjs | 5 ++ .../js/push_to_pull_request_branch.test.cjs | 25 ++++-- pkg/workflow/js/update_issue.test.cjs | 14 ++-- 10 files changed, 133 insertions(+), 106 deletions(-) diff --git a/pkg/workflow/js/add_comment.test.cjs b/pkg/workflow/js/add_comment.test.cjs index 60566cc3a31..226b3577be5 100644 --- a/pkg/workflow/js/add_comment.test.cjs +++ b/pkg/workflow/js/add_comment.test.cjs @@ -134,7 +134,7 @@ describe("add_comment.cjs", () => { }); it("should skip when not in issue or PR context", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_comment", @@ -154,7 +154,7 @@ describe("add_comment.cjs", () => { }); it("should create comment on issue successfully", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_comment", @@ -190,7 +190,7 @@ describe("add_comment.cjs", () => { }); it("should create comment on pull request successfully", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_comment", @@ -223,7 +223,7 @@ describe("add_comment.cjs", () => { }); it("should include run information in comment body", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_comment", @@ -256,7 +256,7 @@ describe("add_comment.cjs", () => { }); it("should include workflow source in footer when GITHUB_AW_WORKFLOW_SOURCE is provided", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_comment", @@ -294,7 +294,7 @@ describe("add_comment.cjs", () => { }); it("should not include workflow source footer when GITHUB_AW_WORKFLOW_SOURCE is not provided", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_comment", @@ -330,7 +330,7 @@ describe("add_comment.cjs", () => { }); it("should use GITHUB_SERVER_URL when repository context is not available", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_comment", @@ -369,7 +369,7 @@ describe("add_comment.cjs", () => { }); it("should fallback to https://github.com when GITHUB_SERVER_URL is not set and repository context is missing", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_comment", @@ -404,7 +404,7 @@ describe("add_comment.cjs", () => { }); it("should include triggering issue number in footer when in issue context", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_comment", @@ -437,7 +437,7 @@ describe("add_comment.cjs", () => { }); it("should include triggering PR number in footer when in PR context", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_comment", diff --git a/pkg/workflow/js/add_labels.test.cjs b/pkg/workflow/js/add_labels.test.cjs index f54128e21e0..5588ffb1e83 100644 --- a/pkg/workflow/js/add_labels.test.cjs +++ b/pkg/workflow/js/add_labels.test.cjs @@ -135,7 +135,7 @@ describe("add_labels.cjs", () => { }); it("should work when allowed labels are not provided (any labels allowed)", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_labels", @@ -160,7 +160,7 @@ describe("add_labels.cjs", () => { }); it("should work when allowed labels list is empty (any labels allowed)", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_labels", @@ -185,7 +185,7 @@ describe("add_labels.cjs", () => { }); it("should enforce allowed labels when restrictions are set", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_labels", @@ -210,7 +210,7 @@ describe("add_labels.cjs", () => { }); it("should fail when max count is invalid", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_labels", @@ -229,7 +229,7 @@ describe("add_labels.cjs", () => { }); it("should fail when max count is zero", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_labels", @@ -248,7 +248,7 @@ describe("add_labels.cjs", () => { }); it("should use default max count when not specified", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_labels", @@ -274,7 +274,7 @@ describe("add_labels.cjs", () => { describe("Context validation", () => { it("should skip when not in issue or PR context (with default target)", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_labels", @@ -295,7 +295,7 @@ describe("add_labels.cjs", () => { }); it("should work with issue_comment event", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_labels", @@ -313,7 +313,7 @@ describe("add_labels.cjs", () => { }); it("should work with pull_request event", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_labels", @@ -338,7 +338,7 @@ describe("add_labels.cjs", () => { }); it("should work with pull_request_review event", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_labels", @@ -363,7 +363,7 @@ describe("add_labels.cjs", () => { }); it("should fail when issue context detected but no issue in payload", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_labels", @@ -383,7 +383,7 @@ describe("add_labels.cjs", () => { }); it("should fail when PR context detected but no PR in payload", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_labels", @@ -406,7 +406,7 @@ describe("add_labels.cjs", () => { describe("Label parsing and validation", () => { it("should parse labels from agent output and add valid ones", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_labels", @@ -432,7 +432,7 @@ describe("add_labels.cjs", () => { }); it("should skip empty lines in agent output", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_labels", @@ -454,7 +454,7 @@ describe("add_labels.cjs", () => { }); it("should fail when line starts with dash (removal indication)", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_labels", @@ -472,7 +472,7 @@ describe("add_labels.cjs", () => { }); it("should remove duplicate labels", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_labels", @@ -494,7 +494,7 @@ describe("add_labels.cjs", () => { }); it("should enforce max count limit", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_labels", @@ -518,7 +518,7 @@ describe("add_labels.cjs", () => { }); it("should skip when no valid labels found", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_labels", @@ -540,7 +540,7 @@ describe("add_labels.cjs", () => { describe("GitHub API integration", () => { it("should successfully add labels to issue", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_labels", @@ -572,7 +572,7 @@ describe("add_labels.cjs", () => { }); it("should successfully add labels to pull request", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_labels", @@ -599,7 +599,7 @@ describe("add_labels.cjs", () => { }); it("should handle GitHub API errors", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_labels", @@ -622,7 +622,7 @@ describe("add_labels.cjs", () => { }); it("should handle non-Error objects in catch block", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_labels", @@ -647,7 +647,7 @@ describe("add_labels.cjs", () => { describe("Output and logging", () => { it("should log agent output content length", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_labels", @@ -664,7 +664,7 @@ describe("add_labels.cjs", () => { }); it("should log allowed labels and max count", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_labels", @@ -683,7 +683,7 @@ describe("add_labels.cjs", () => { }); it("should log requested labels", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_labels", @@ -700,7 +700,7 @@ describe("add_labels.cjs", () => { }); it("should log final labels being added", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_labels", @@ -719,7 +719,7 @@ describe("add_labels.cjs", () => { describe("Edge cases", () => { it("should handle whitespace in allowed labels", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_labels", @@ -742,7 +742,7 @@ describe("add_labels.cjs", () => { }); it("should handle empty entries in allowed labels", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_labels", @@ -759,7 +759,7 @@ describe("add_labels.cjs", () => { }); it("should handle single label output", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_labels", @@ -785,7 +785,7 @@ describe("add_labels.cjs", () => { }); it("should handle duplicate labels by removing duplicates", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_labels", @@ -808,7 +808,7 @@ describe("add_labels.cjs", () => { }); it("should sanitize labels by removing problematic characters", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_labels", @@ -834,7 +834,7 @@ describe("add_labels.cjs", () => { it("should limit label length to 64 characters", async () => { const longLabel = "a".repeat(100); - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_labels", @@ -855,7 +855,7 @@ describe("add_labels.cjs", () => { }); it("should remove empty and whitespace-only labels", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_labels", @@ -885,7 +885,7 @@ describe("add_labels.cjs", () => { }); it("should use triggering issue when target is not specified (default behavior)", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_labels", @@ -912,7 +912,7 @@ describe("add_labels.cjs", () => { }); it("should use triggering issue when target is explicitly set to 'triggering'", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_labels", @@ -940,7 +940,7 @@ describe("add_labels.cjs", () => { }); it("should skip when target is 'triggering' but not in issue context", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_labels", @@ -965,7 +965,7 @@ describe("add_labels.cjs", () => { }); it("should use explicit issue number from target configuration", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_labels", @@ -994,7 +994,7 @@ describe("add_labels.cjs", () => { }); it("should use item_number from labels item when target is '*'", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_labels", @@ -1024,7 +1024,7 @@ describe("add_labels.cjs", () => { }); it("should fail when target is '*' but no item_number in labels item", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_labels", @@ -1042,7 +1042,7 @@ describe("add_labels.cjs", () => { }); it("should fail when target has invalid issue number", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_labels", @@ -1060,7 +1060,7 @@ describe("add_labels.cjs", () => { }); it("should fail when target is '*' and issue_number in item is invalid", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "add_labels", diff --git a/pkg/workflow/js/create_code_scanning_alert.test.cjs b/pkg/workflow/js/create_code_scanning_alert.test.cjs index 0c21d2660f6..ed21e925ddc 100644 --- a/pkg/workflow/js/create_code_scanning_alert.test.cjs +++ b/pkg/workflow/js/create_code_scanning_alert.test.cjs @@ -67,7 +67,6 @@ global.context = mockContext; const securityReportScript = fs.readFileSync(path.join(import.meta.dirname, "create_code_scanning_alert.cjs"), "utf8"); describe("create_code_scanning_alert.cjs", () => { - let securityReportScript; let tempFilePath; // Helper function to set agent output via file @@ -111,6 +110,7 @@ describe("create_code_scanning_alert.cjs", () => { describe("main function", () => { it("should handle missing environment variable", async () => { + delete process.env.GITHUB_AW_AGENT_OUTPUT; await eval(`(async () => { ${securityReportScript} })()`); expect(mockCore.info).toHaveBeenCalledWith("No GITHUB_AW_AGENT_OUTPUT environment variable found"); @@ -131,7 +131,7 @@ describe("create_code_scanning_alert.cjs", () => { }); it("should handle missing items array", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ status: "success", }); await eval(`(async () => { ${securityReportScript} })()`); @@ -140,7 +140,7 @@ describe("create_code_scanning_alert.cjs", () => { }); it("should handle no code scanning alert items", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [{ type: "create_issue", title: "Test Issue" }], }); await eval(`(async () => { ${securityReportScript} })()`); diff --git a/pkg/workflow/js/create_issue.test.cjs b/pkg/workflow/js/create_issue.test.cjs index 1e56dd66116..6c2537df1bd 100644 --- a/pkg/workflow/js/create_issue.test.cjs +++ b/pkg/workflow/js/create_issue.test.cjs @@ -133,7 +133,7 @@ describe("create_issue.cjs", () => { }); it("should create issue with default title when only body content provided", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "create_issue", @@ -165,7 +165,7 @@ describe("create_issue.cjs", () => { }); it("should extract title from markdown heading", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "create_issue", @@ -192,7 +192,7 @@ describe("create_issue.cjs", () => { }); it("should handle labels from environment variable", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "create_issue", @@ -218,7 +218,7 @@ describe("create_issue.cjs", () => { }); it("should apply title prefix when provided", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "create_issue", @@ -244,7 +244,7 @@ describe("create_issue.cjs", () => { }); it("should not duplicate title prefix when already present", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "create_issue", @@ -270,7 +270,7 @@ describe("create_issue.cjs", () => { }); it("should handle parent issue context and create comment", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "create_issue", @@ -317,7 +317,7 @@ describe("create_issue.cjs", () => { }); it("should handle empty labels gracefully", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "create_issue", @@ -343,7 +343,7 @@ describe("create_issue.cjs", () => { }); it("should include run information in issue body", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "create_issue", @@ -369,7 +369,7 @@ describe("create_issue.cjs", () => { }); it("should handle disabled issues repository gracefully", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "create_issue", @@ -407,7 +407,7 @@ describe("create_issue.cjs", () => { }); it("should continue processing other issues when one fails due to disabled repository", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "create_issue", @@ -442,7 +442,7 @@ describe("create_issue.cjs", () => { }); it("should handle duplicate labels by removing duplicates", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "create_issue", @@ -471,7 +471,7 @@ describe("create_issue.cjs", () => { }); it("should sanitize labels by removing problematic characters", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "create_issue", @@ -499,7 +499,7 @@ describe("create_issue.cjs", () => { it("should limit label length to 64 characters", async () => { const longLabel = "a".repeat(100); // 100 character label - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "create_issue", @@ -528,7 +528,7 @@ describe("create_issue.cjs", () => { }); it("should remove empty and whitespace-only labels", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "create_issue", @@ -555,7 +555,7 @@ describe("create_issue.cjs", () => { }); it("should include workflow source in footer when GITHUB_AW_WORKFLOW_SOURCE is provided", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "create_issue", @@ -590,7 +590,7 @@ describe("create_issue.cjs", () => { }); it("should not include workflow source footer when GITHUB_AW_WORKFLOW_SOURCE is not provided", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "create_issue", @@ -623,7 +623,7 @@ describe("create_issue.cjs", () => { }); it("should include triggering issue number in footer when in issue context", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "create_issue", @@ -661,7 +661,7 @@ describe("create_issue.cjs", () => { }); it("should include triggering PR number in footer when in PR context", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "create_issue", @@ -697,7 +697,7 @@ describe("create_issue.cjs", () => { }); it("should not include triggering reference when no context available", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "create_issue", diff --git a/pkg/workflow/js/create_pr_review_comment.test.cjs b/pkg/workflow/js/create_pr_review_comment.test.cjs index 47752467155..9fcd240d707 100644 --- a/pkg/workflow/js/create_pr_review_comment.test.cjs +++ b/pkg/workflow/js/create_pr_review_comment.test.cjs @@ -126,7 +126,7 @@ describe("create_pr_review_comment.cjs", () => { }); // Set up environment - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "create_pull_request_review_comment", @@ -167,7 +167,7 @@ describe("create_pr_review_comment.cjs", () => { }); // Set up environment with multi-line comment - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "create_pull_request_review_comment", @@ -215,7 +215,7 @@ describe("create_pr_review_comment.cjs", () => { }); // Set up environment with multiple comments - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "create_pull_request_review_comment", @@ -253,7 +253,7 @@ describe("create_pr_review_comment.cjs", () => { }); // Set up environment with custom side - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "create_pull_request_review_comment", @@ -287,7 +287,7 @@ describe("create_pr_review_comment.cjs", () => { }, }; - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "create_pull_request_review_comment", @@ -307,7 +307,7 @@ describe("create_pr_review_comment.cjs", () => { }); it("should validate required fields and skip invalid items", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "create_pull_request_review_comment", @@ -345,7 +345,7 @@ describe("create_pr_review_comment.cjs", () => { }); it("should validate start_line is not greater than line", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "create_pull_request_review_comment", @@ -365,7 +365,7 @@ describe("create_pr_review_comment.cjs", () => { }); it("should validate side values", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "create_pull_request_review_comment", @@ -392,7 +392,7 @@ describe("create_pr_review_comment.cjs", () => { }, }); - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "create_pull_request_review_comment", @@ -434,7 +434,7 @@ describe("create_pr_review_comment.cjs", () => { }, }); - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "create_pull_request_review_comment", @@ -486,7 +486,7 @@ describe("create_pr_review_comment.cjs", () => { }, }); - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "create_pull_request_review_comment", @@ -523,7 +523,7 @@ describe("create_pr_review_comment.cjs", () => { // Set target to "*" process.env.GITHUB_AW_PR_REVIEW_COMMENT_TARGET = "*"; - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "create_pull_request_review_comment", @@ -563,7 +563,7 @@ describe("create_pr_review_comment.cjs", () => { }, }; - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "create_pull_request_review_comment", @@ -582,7 +582,7 @@ describe("create_pr_review_comment.cjs", () => { }); it("should include workflow source in footer when GITHUB_AW_WORKFLOW_SOURCE is provided", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "create_pull_request_review_comment", @@ -641,7 +641,7 @@ describe("create_pr_review_comment.cjs", () => { }); it("should not include workflow source footer when GITHUB_AW_WORKFLOW_SOURCE is not provided", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "create_pull_request_review_comment", @@ -698,7 +698,7 @@ describe("create_pr_review_comment.cjs", () => { }); it("should include triggering PR number in footer when in PR context", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "create_pull_request_review_comment", diff --git a/pkg/workflow/js/create_pull_request.test.cjs b/pkg/workflow/js/create_pull_request.test.cjs index b0f1bdaf0b9..b0a57264fa6 100644 --- a/pkg/workflow/js/create_pull_request.test.cjs +++ b/pkg/workflow/js/create_pull_request.test.cjs @@ -58,7 +58,15 @@ describe("create_pull_request.cjs", () => { mockDependencies = { fs: { existsSync: vi.fn().mockReturnValue(true), - readFileSync: vi.fn().mockReturnValue("diff --git a/file.txt b/file.txt\n+new content"), + readFileSync: vi.fn().mockImplementation((filepath) => { + // If reading the agent output file, return the JSON content from the env var + // (in this test setup, the env var contains JSON directly, not a file path) + if (filepath === mockDependencies.process.env.GITHUB_AW_AGENT_OUTPUT) { + return mockDependencies.process.env.GITHUB_AW_AGENT_OUTPUT; + } + // Otherwise return the patch content + return "diff --git a/file.txt b/file.txt\n+new content"; + }), }, crypto: { randomBytes: vi.fn().mockReturnValue(Buffer.from("1234567890abcdef", "hex")), diff --git a/pkg/workflow/js/missing_tool.cjs b/pkg/workflow/js/missing_tool.cjs index 72360856739..c334ed97c3c 100644 --- a/pkg/workflow/js/missing_tool.cjs +++ b/pkg/workflow/js/missing_tool.cjs @@ -30,6 +30,13 @@ async function main() { return; } + if (agentOutput.trim() === "") { + core.info("No agent output to process"); + core.setOutput("tools_reported", JSON.stringify(missingTools)); + core.setOutput("total_count", missingTools.length.toString()); + return; + } + core.info(`Agent output length: ${agentOutput.length}`); // Parse the validated output JSON diff --git a/pkg/workflow/js/push_to_pull_request_branch.cjs b/pkg/workflow/js/push_to_pull_request_branch.cjs index 24a65830e6b..91cdd767ae0 100644 --- a/pkg/workflow/js/push_to_pull_request_branch.cjs +++ b/pkg/workflow/js/push_to_pull_request_branch.cjs @@ -21,6 +21,11 @@ async function main() { return; } + if (outputContent.trim() === "") { + core.info("Agent output content is empty"); + return; + } + const target = process.env.GITHUB_AW_PUSH_TARGET || "triggering"; const ifNoChanges = process.env.GITHUB_AW_PUSH_IF_NO_CHANGES || "warn"; diff --git a/pkg/workflow/js/push_to_pull_request_branch.test.cjs b/pkg/workflow/js/push_to_pull_request_branch.test.cjs index 049130a3b87..089670dc193 100644 --- a/pkg/workflow/js/push_to_pull_request_branch.test.cjs +++ b/pkg/workflow/js/push_to_pull_request_branch.test.cjs @@ -98,7 +98,14 @@ describe("push_to_pull_request_branch.cjs", () => { // Create fresh mock objects for each test mockFs = { existsSync: vi.fn(), - readFileSync: vi.fn(), + readFileSync: vi.fn().mockImplementation((filepath) => { + // If reading the agent output file, read the actual temp file + if (filepath === process.env.GITHUB_AW_AGENT_OUTPUT) { + return fs.readFileSync(filepath, "utf8"); + } + // Otherwise return the mock patch content (will be overridden by individual tests) + return "diff --git a/file.txt b/file.txt\n+new content"; + }), }; // Create fresh mock for exec @@ -197,7 +204,7 @@ const exec = global.exec;` }); it("should handle missing patch file with default 'warn' behavior", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [{ type: "push_to_pull_request_branch", content: "test" }], }); @@ -211,7 +218,7 @@ const exec = global.exec;` }); it("should fail when patch file missing and if-no-changes is 'error'", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [{ type: "push_to_pull_request_branch", content: "test" }], }); process.env.GITHUB_AW_PUSH_IF_NO_CHANGES = "error"; @@ -225,7 +232,7 @@ const exec = global.exec;` }); it("should silently succeed when patch file missing and if-no-changes is 'ignore'", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [{ type: "push_to_pull_request_branch", content: "test" }], }); process.env.GITHUB_AW_PUSH_IF_NO_CHANGES = "ignore"; @@ -240,7 +247,7 @@ const exec = global.exec;` }); it("should handle patch file with error content", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [{ type: "push_to_pull_request_branch", content: "test" }], }); @@ -255,7 +262,7 @@ const exec = global.exec;` }); it("should handle empty patch file with default 'warn' behavior", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [{ type: "push_to_pull_request_branch", content: "test" }], }); @@ -273,7 +280,7 @@ const exec = global.exec;` }); it("should fail when empty patch and if-no-changes is 'error'", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [{ type: "push_to_pull_request_branch", content: "test" }], }); process.env.GITHUB_AW_PUSH_IF_NO_CHANGES = "error"; @@ -326,7 +333,7 @@ const exec = global.exec;` }); it("should handle agent output without valid items array", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: "not an array", }); @@ -341,7 +348,7 @@ const exec = global.exec;` }); it("should use custom target configuration", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [{ type: "push_to_pull_request_branch", content: "test" }], }); process.env.GITHUB_AW_PUSH_TARGET = "custom-target"; diff --git a/pkg/workflow/js/update_issue.test.cjs b/pkg/workflow/js/update_issue.test.cjs index 7ac80da0577..3d75bab5099 100644 --- a/pkg/workflow/js/update_issue.test.cjs +++ b/pkg/workflow/js/update_issue.test.cjs @@ -132,7 +132,7 @@ describe("update_issue.cjs", () => { }); it("should skip when not in issue context for triggering target", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "update_issue", @@ -151,7 +151,7 @@ describe("update_issue.cjs", () => { }); it("should update issue title successfully", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "update_issue", @@ -187,7 +187,7 @@ describe("update_issue.cjs", () => { }); it("should update issue status successfully", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "update_issue", @@ -217,7 +217,7 @@ describe("update_issue.cjs", () => { }); it("should update multiple fields successfully", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "update_issue", @@ -253,7 +253,7 @@ describe("update_issue.cjs", () => { }); it('should handle explicit issue number with target "*"', async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "update_issue", @@ -285,7 +285,7 @@ describe("update_issue.cjs", () => { }); it("should skip when no valid updates are provided", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "update_issue", @@ -307,7 +307,7 @@ describe("update_issue.cjs", () => { }); it("should validate status values", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({ + setAgentOutput({ items: [ { type: "update_issue", From 9f80b8598b4f484ec5d515afa611ec690cb0a618 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 17 Oct 2025 20:31:32 +0000 Subject: [PATCH 3/4] Fix all remaining JavaScript test failures - all 534 tests now passing Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- pkg/workflow/js/create_pull_request.test.cjs | 51 ++++++++------ .../js/push_to_pull_request_branch.test.cjs | 67 +++++++++++++------ 2 files changed, 77 insertions(+), 41 deletions(-) diff --git a/pkg/workflow/js/create_pull_request.test.cjs b/pkg/workflow/js/create_pull_request.test.cjs index b0a57264fa6..6ac91fdc478 100644 --- a/pkg/workflow/js/create_pull_request.test.cjs +++ b/pkg/workflow/js/create_pull_request.test.cjs @@ -38,6 +38,19 @@ describe("create_pull_request.cjs", () => { fs.writeFileSync(tempFilePath, content); process.env.GITHUB_AW_AGENT_OUTPUT = tempFilePath; }; + + // Helper to mock patch file content while preserving agent output reading + const mockPatchContent = (mockDeps, patchContent) => { + mockDeps.fs.readFileSync.mockImplementation(filepath => { + // If reading the agent output file, return the JSON content from env var + if (filepath === mockDeps.process.env.GITHUB_AW_AGENT_OUTPUT) { + return mockDeps.process.env.GITHUB_AW_AGENT_OUTPUT; + } + // Otherwise return the patch content + return patchContent; + }); + }; + let mockDependencies; beforeEach(() => { @@ -58,7 +71,7 @@ describe("create_pull_request.cjs", () => { mockDependencies = { fs: { existsSync: vi.fn().mockReturnValue(true), - readFileSync: vi.fn().mockImplementation((filepath) => { + readFileSync: vi.fn().mockImplementation(filepath => { // If reading the agent output file, return the JSON content from the env var // (in this test setup, the env var contains JSON directly, not a file path) if (filepath === mockDependencies.process.env.GITHUB_AW_AGENT_OUTPUT) { @@ -193,7 +206,7 @@ describe("create_pull_request.cjs", () => { it("should handle empty patch with default warn behavior when patch file is empty", async () => { mockDependencies.process.env.GITHUB_AW_WORKFLOW_ID = "test-workflow"; mockDependencies.process.env.GITHUB_AW_BASE_BRANCH = "main"; - mockDependencies.fs.readFileSync.mockReturnValue(" "); + mockPatchContent(mockDependencies, " "); const mainFunction = createMainFunction(mockDependencies); @@ -587,7 +600,7 @@ describe("create_pull_request.cjs", () => { patchLines.push(`+Line ${i}`); } const largePatch = patchLines.join("\n"); - mockDependencies.fs.readFileSync.mockReturnValue(largePatch); + mockPatchContent(mockDependencies, largePatch); // Mock PR creation to fail const prError = new Error("Pull request creation is disabled"); @@ -641,7 +654,7 @@ describe("create_pull_request.cjs", () => { patchLines.push(`+This is a longer line ${i} with more content to trigger character limit truncation`); } const largePatch = patchLines.join("\n"); - mockDependencies.fs.readFileSync.mockReturnValue(largePatch); + mockPatchContent(mockDependencies, largePatch); // Mock PR creation to fail const prError = new Error("Pull request creation is disabled"); @@ -692,7 +705,7 @@ describe("create_pull_request.cjs", () => { // Create a small patch (under 500 lines) const smallPatch = "diff --git a/file.txt b/file.txt\n--- a/file.txt\n+++ b/file.txt\n@@ -1,1 +1,1 @@\n+Small change"; - mockDependencies.fs.readFileSync.mockReturnValue(smallPatch); + mockPatchContent(mockDependencies, smallPatch); // Mock PR creation to fail const prError = new Error("Pull request creation is disabled"); @@ -874,7 +887,7 @@ describe("create_pull_request.cjs", () => { patchLines.push(`+Test line ${i}`); } const testPatch = patchLines.join("\n"); - mockDependencies.fs.readFileSync.mockReturnValue(testPatch); + mockPatchContent(mockDependencies, testPatch); // Mock git push to fail global.exec.exec = vi.fn().mockImplementation(async (cmd, args, options) => { @@ -1072,7 +1085,7 @@ describe("create_pull_request.cjs", () => { }); it("should handle empty patch with warn (default) behavior", async () => { - mockDependencies.fs.readFileSync.mockReturnValue(""); + mockPatchContent(mockDependencies, ""); mockDependencies.process.env.GITHUB_AW_PR_IF_NO_CHANGES = "warn"; const mainFunction = createMainFunction(mockDependencies); @@ -1084,7 +1097,7 @@ describe("create_pull_request.cjs", () => { }); it("should handle empty patch with ignore behavior", async () => { - mockDependencies.fs.readFileSync.mockReturnValue(""); + mockPatchContent(mockDependencies, ""); mockDependencies.process.env.GITHUB_AW_PR_IF_NO_CHANGES = "ignore"; const mainFunction = createMainFunction(mockDependencies); @@ -1096,7 +1109,7 @@ describe("create_pull_request.cjs", () => { }); it("should handle empty patch with error behavior", async () => { - mockDependencies.fs.readFileSync.mockReturnValue(""); + mockPatchContent(mockDependencies, ""); mockDependencies.process.env.GITHUB_AW_PR_IF_NO_CHANGES = "error"; const mainFunction = createMainFunction(mockDependencies); @@ -1140,7 +1153,7 @@ describe("create_pull_request.cjs", () => { }); it("should handle patch with error message with warn behavior", async () => { - mockDependencies.fs.readFileSync.mockReturnValue("Failed to generate patch: some error"); + mockPatchContent(mockDependencies, "Failed to generate patch: some error"); mockDependencies.process.env.GITHUB_AW_PR_IF_NO_CHANGES = "warn"; const mainFunction = createMainFunction(mockDependencies); @@ -1154,7 +1167,7 @@ describe("create_pull_request.cjs", () => { }); it("should default to warn when if-no-changes is not specified", async () => { - mockDependencies.fs.readFileSync.mockReturnValue(""); + mockPatchContent(mockDependencies, ""); // Don't set GITHUB_AW_PR_IF_NO_CHANGES env var const mainFunction = createMainFunction(mockDependencies); @@ -1205,7 +1218,7 @@ describe("create_pull_request.cjs", () => { it("should include patch information in staged mode summary", async () => { mockDependencies.process.env.GITHUB_AW_SAFE_OUTPUTS_STAGED = "true"; - mockDependencies.fs.readFileSync.mockReturnValue("diff --git a/test.txt b/test.txt\n+added line\n-removed line"); + mockPatchContent(mockDependencies, "diff --git a/test.txt b/test.txt\n+added line\n-removed line"); const mainFunction = createMainFunction(mockDependencies); @@ -1224,7 +1237,7 @@ describe("create_pull_request.cjs", () => { it("should handle empty patch in staged mode", async () => { mockDependencies.process.env.GITHUB_AW_SAFE_OUTPUTS_STAGED = "true"; - mockDependencies.fs.readFileSync.mockReturnValue(""); + mockPatchContent(mockDependencies, ""); const mainFunction = createMainFunction(mockDependencies); @@ -1295,7 +1308,7 @@ describe("create_pull_request.cjs", () => { it("should handle patch error in staged mode", async () => { mockDependencies.process.env.GITHUB_AW_SAFE_OUTPUTS_STAGED = "true"; - mockDependencies.fs.readFileSync.mockReturnValue("Failed to generate patch: some error occurred"); + mockPatchContent(mockDependencies, "Failed to generate patch: some error occurred"); const mainFunction = createMainFunction(mockDependencies); @@ -1327,7 +1340,7 @@ describe("create_pull_request.cjs", () => { mockDependencies.fs.existsSync.mockReturnValue(true); // Create patch content under 10 KB (approximately 5 KB) const patchContent = "diff --git a/file.txt b/file.txt\n+new content\n".repeat(100); - mockDependencies.fs.readFileSync.mockReturnValue(patchContent); + mockPatchContent(mockDependencies, patchContent); const mockPullRequest = { number: 123, @@ -1362,7 +1375,7 @@ describe("create_pull_request.cjs", () => { mockDependencies.fs.existsSync.mockReturnValue(true); // Create patch content over 1 KB (approximately 5 KB) const patchContent = "diff --git a/file.txt b/file.txt\n+new content\n".repeat(100); - mockDependencies.fs.readFileSync.mockReturnValue(patchContent); + mockPatchContent(mockDependencies, patchContent); const main = createMainFunction(mockDependencies); @@ -1388,7 +1401,7 @@ describe("create_pull_request.cjs", () => { mockDependencies.fs.existsSync.mockReturnValue(true); // Create patch content over 1 KB (approximately 5 KB) const patchContent = "diff --git a/file.txt b/file.txt\n+new content\n".repeat(100); - mockDependencies.fs.readFileSync.mockReturnValue(patchContent); + mockPatchContent(mockDependencies, patchContent); const main = createMainFunction(mockDependencies); await main(); @@ -1420,7 +1433,7 @@ describe("create_pull_request.cjs", () => { mockDependencies.fs.existsSync.mockReturnValue(true); const patchContent = "diff --git a/file.txt b/file.txt\n+new content\n"; - mockDependencies.fs.readFileSync.mockReturnValue(patchContent); + mockPatchContent(mockDependencies, patchContent); const mockPullRequest = { number: 123, @@ -1452,7 +1465,7 @@ describe("create_pull_request.cjs", () => { mockDependencies.process.env.GITHUB_AW_MAX_PATCH_SIZE = "1"; // 1 KB limit mockDependencies.fs.existsSync.mockReturnValue(true); - mockDependencies.fs.readFileSync.mockReturnValue(""); // Empty patch + mockPatchContent(mockDependencies, ""); // Empty patch const main = createMainFunction(mockDependencies); await main(); diff --git a/pkg/workflow/js/push_to_pull_request_branch.test.cjs b/pkg/workflow/js/push_to_pull_request_branch.test.cjs index 089670dc193..3c0aa59029b 100644 --- a/pkg/workflow/js/push_to_pull_request_branch.test.cjs +++ b/pkg/workflow/js/push_to_pull_request_branch.test.cjs @@ -72,6 +72,19 @@ describe("push_to_pull_request_branch.cjs", () => { process.env.GITHUB_AW_AGENT_OUTPUT = tempFilePath; }; + // Helper function to mock patch file content while preserving agent output file reading + const mockPatchContent = patchContent => { + mockFs.readFileSync.mockImplementation((filepath, encoding) => { + // If reading the agent output file, always read the actual temp file + const agentOutputPath = process.env.GITHUB_AW_AGENT_OUTPUT; + if (agentOutputPath && filepath === agentOutputPath) { + return fs.readFileSync(filepath, encoding || "utf8"); + } + // For patch files, return the mocked content + return patchContent; + }); + }; + // Helper function to execute the script with proper globals const executeScript = async () => { // Set globals just before execution @@ -98,12 +111,14 @@ describe("push_to_pull_request_branch.cjs", () => { // Create fresh mock objects for each test mockFs = { existsSync: vi.fn(), - readFileSync: vi.fn().mockImplementation((filepath) => { - // If reading the agent output file, read the actual temp file - if (filepath === process.env.GITHUB_AW_AGENT_OUTPUT) { - return fs.readFileSync(filepath, "utf8"); + readFileSync: vi.fn().mockImplementation((filepath, encoding) => { + // If reading the agent output file, always read the actual temp file + const agentOutputPath = process.env.GITHUB_AW_AGENT_OUTPUT; + if (agentOutputPath && filepath === agentOutputPath) { + return fs.readFileSync(filepath, encoding || "utf8"); } - // Otherwise return the mock patch content (will be overridden by individual tests) + // For all other files (like patch files), return a default or let individual tests override + // Default return value for patch files return "diff --git a/file.txt b/file.txt\n+new content"; }), }; @@ -252,7 +267,7 @@ const exec = global.exec;` }); mockFs.existsSync.mockReturnValue(true); - mockFs.readFileSync.mockReturnValue("Failed to generate patch: some error"); + mockPatchContent("Failed to generate patch: some error"); // Execute the script await executeScript(); @@ -267,7 +282,7 @@ const exec = global.exec;` }); mockFs.existsSync.mockReturnValue(true); - mockFs.readFileSync.mockReturnValue(""); + mockPatchContent(""); // Mock the git command to return a branch name @@ -286,7 +301,7 @@ const exec = global.exec;` process.env.GITHUB_AW_PUSH_IF_NO_CHANGES = "error"; mockFs.existsSync.mockReturnValue(true); - mockFs.readFileSync.mockReturnValue(" "); + mockPatchContent(" "); // Execute the script await executeScript(); @@ -307,7 +322,7 @@ const exec = global.exec;` setAgentOutput(validOutput); mockFs.existsSync.mockReturnValue(true); - mockFs.readFileSync.mockReturnValue("diff --git a/file.txt b/file.txt\n+new content"); + mockPatchContent("diff --git a/file.txt b/file.txt\n+new content"); // Mock the git commands that will be called @@ -321,15 +336,23 @@ const exec = global.exec;` }); it("should handle invalid JSON in agent output", async () => { - process.env.GITHUB_AW_AGENT_OUTPUT = "invalid json content"; + // Create a temp file with invalid JSON + const invalidJsonPath = path.join("/tmp", `test_invalid_${Date.now()}.json`); + fs.writeFileSync(invalidJsonPath, "invalid json content"); + process.env.GITHUB_AW_AGENT_OUTPUT = invalidJsonPath; mockFs.existsSync.mockReturnValue(true); - mockFs.readFileSync.mockReturnValue("some patch content"); + mockPatchContent("some patch content"); // Execute the script await executeScript(); expect(mockCore.setFailed).toHaveBeenCalledWith(expect.stringMatching(/Error parsing agent output JSON:/)); + + // Clean up + if (fs.existsSync(invalidJsonPath)) { + fs.unlinkSync(invalidJsonPath); + } }); it("should handle agent output without valid items array", async () => { @@ -338,7 +361,7 @@ const exec = global.exec;` }); mockFs.existsSync.mockReturnValue(true); - mockFs.readFileSync.mockReturnValue("some patch content"); + mockPatchContent("some patch content"); // Execute the script await executeScript(); @@ -354,7 +377,7 @@ const exec = global.exec;` process.env.GITHUB_AW_PUSH_TARGET = "custom-target"; mockFs.existsSync.mockReturnValue(true); - mockFs.readFileSync.mockReturnValue("some patch content"); + mockPatchContent("some patch content"); // Mock the git commands @@ -401,7 +424,7 @@ const exec = global.exec;` mockFs.existsSync.mockReturnValue(true); // Create patch content under 10 KB (approximately 5 KB) const patchContent = "diff --git a/file.txt b/file.txt\n+new content\n".repeat(100); - mockFs.readFileSync.mockReturnValue(patchContent); + mockPatchContent(patchContent); // Mock the git commands that will be called @@ -429,7 +452,7 @@ const exec = global.exec;` mockFs.existsSync.mockReturnValue(true); // Create patch content over 1 KB (approximately 5 KB) const patchContent = "diff --git a/file.txt b/file.txt\n+new content\n".repeat(100); - mockFs.readFileSync.mockReturnValue(patchContent); + mockPatchContent(patchContent); // Execute the script await executeScript(); @@ -453,7 +476,7 @@ const exec = global.exec;` mockFs.existsSync.mockReturnValue(true); const patchContent = "diff --git a/file.txt b/file.txt\n+new content\n"; - mockFs.readFileSync.mockReturnValue(patchContent); + mockPatchContent(patchContent); // Mock the git commands that will be called @@ -479,7 +502,7 @@ const exec = global.exec;` process.env.GITHUB_AW_MAX_PATCH_SIZE = "1"; // 1 KB limit mockFs.existsSync.mockReturnValue(true); - mockFs.readFileSync.mockReturnValue(""); // Empty patch + mockPatchContent(""); // Empty patch // Mock the git commands that will be called @@ -505,7 +528,7 @@ const exec = global.exec;` process.env.GITHUB_AW_PR_TITLE_PREFIX = "[bot] "; mockFs.existsSync.mockReturnValue(true); - mockFs.readFileSync.mockReturnValue("diff --git a/file.txt b/file.txt\n+new content"); + mockPatchContent("diff --git a/file.txt b/file.txt\n+new content"); // Mock the gh pr view command to return PR data with matching title prefix mockExec.getExecOutput.mockImplementation((command, args) => { @@ -552,7 +575,7 @@ const exec = global.exec;` process.env.GITHUB_AW_PR_TITLE_PREFIX = "[bot] "; mockFs.existsSync.mockReturnValue(true); - mockFs.readFileSync.mockReturnValue("diff --git a/file.txt b/file.txt\n+new content"); + mockPatchContent("diff --git a/file.txt b/file.txt\n+new content"); // Mock the gh pr view command to return PR data without matching title prefix mockExec.getExecOutput.mockImplementation((command, args) => { @@ -598,7 +621,7 @@ const exec = global.exec;` process.env.GITHUB_AW_PR_LABELS = "automation,enhancement"; mockFs.existsSync.mockReturnValue(true); - mockFs.readFileSync.mockReturnValue("diff --git a/file.txt b/file.txt\n+new content"); + mockPatchContent("diff --git a/file.txt b/file.txt\n+new content"); // Mock the gh pr view command to return PR data with required labels mockExec.getExecOutput.mockImplementation((command, args) => { @@ -645,7 +668,7 @@ const exec = global.exec;` process.env.GITHUB_AW_PR_LABELS = "automation,enhancement"; mockFs.existsSync.mockReturnValue(true); - mockFs.readFileSync.mockReturnValue("diff --git a/file.txt b/file.txt\n+new content"); + mockPatchContent("diff --git a/file.txt b/file.txt\n+new content"); // Mock the gh pr view command to return PR data missing required labels mockExec.getExecOutput.mockImplementation((command, args) => { @@ -694,7 +717,7 @@ const exec = global.exec;` process.env.GITHUB_AW_PR_LABELS = "bot,feature"; mockFs.existsSync.mockReturnValue(true); - mockFs.readFileSync.mockReturnValue("diff --git a/file.txt b/file.txt\n+new content"); + mockPatchContent("diff --git a/file.txt b/file.txt\n+new content"); // Mock the gh pr view command to return PR data with both valid title and labels mockExec.getExecOutput.mockImplementation((command, args) => { From c78aec881da57add5f3b3592f56565a440c8d34b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 17 Oct 2025 20:34:11 +0000 Subject: [PATCH 4/4] Complete fix for JavaScript tests - all validation passes Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- .github/workflows/artifacts-summary.lock.yml | 6 ++++++ .github/workflows/audit-workflows.lock.yml | 6 ++++++ .github/workflows/brave.lock.yml | 6 ++++++ .github/workflows/changeset-generator.lock.yml | 10 ++++++++++ .github/workflows/ci-doctor.lock.yml | 6 ++++++ .github/workflows/cli-version-checker.lock.yml | 6 ++++++ .github/workflows/daily-doc-updater.lock.yml | 6 ++++++ .github/workflows/daily-news.lock.yml | 6 ++++++ .github/workflows/dev.lock.yml | 6 ++++++ .github/workflows/duplicate-code-detector.lock.yml | 6 ++++++ .github/workflows/example-workflow-analyzer.lock.yml | 6 ++++++ .github/workflows/github-mcp-tools-report.lock.yml | 6 ++++++ .github/workflows/go-pattern-detector.lock.yml | 6 ++++++ .github/workflows/issue-classifier.lock.yml | 6 ++++++ .github/workflows/lockfile-stats.lock.yml | 6 ++++++ .github/workflows/mcp-inspector.lock.yml | 6 ++++++ .github/workflows/pdf-summary.lock.yml | 6 ++++++ .github/workflows/plan.lock.yml | 6 ++++++ .github/workflows/poem-bot.lock.yml | 10 ++++++++++ .github/workflows/q.lock.yml | 6 ++++++ .github/workflows/repo-tree-map.lock.yml | 6 ++++++ .github/workflows/research.lock.yml | 6 ++++++ .github/workflows/scout.lock.yml | 6 ++++++ .github/workflows/security-fix-pr.lock.yml | 6 ++++++ .github/workflows/smoke-claude.lock.yml | 6 ++++++ .github/workflows/smoke-codex.lock.yml | 6 ++++++ .github/workflows/smoke-copilot.lock.yml | 6 ++++++ .github/workflows/smoke-genaiscript.lock.yml | 6 ++++++ .github/workflows/smoke-opencode.lock.yml | 6 ++++++ .github/workflows/technical-doc-writer.lock.yml | 6 ++++++ .github/workflows/tidy.lock.yml | 10 ++++++++++ .github/workflows/unbloat-docs.lock.yml | 6 ++++++ 32 files changed, 204 insertions(+) diff --git a/.github/workflows/artifacts-summary.lock.yml b/.github/workflows/artifacts-summary.lock.yml index 9e5c25bcfb0..02d4ec28ef5 100644 --- a/.github/workflows/artifacts-summary.lock.yml +++ b/.github/workflows/artifacts-summary.lock.yml @@ -3671,6 +3671,12 @@ jobs: core.setFailed(`Error reading agent output file: ${error instanceof Error ? error.message : String(error)}`); return; } + if (agentOutput.trim() === "") { + core.info("No agent output to process"); + core.setOutput("tools_reported", JSON.stringify(missingTools)); + core.setOutput("total_count", missingTools.length.toString()); + return; + } core.info(`Agent output length: ${agentOutput.length}`); let validatedOutput; try { diff --git a/.github/workflows/audit-workflows.lock.yml b/.github/workflows/audit-workflows.lock.yml index 00240d6ba27..0e4cbb7e0cb 100644 --- a/.github/workflows/audit-workflows.lock.yml +++ b/.github/workflows/audit-workflows.lock.yml @@ -3545,6 +3545,12 @@ jobs: core.setFailed(`Error reading agent output file: ${error instanceof Error ? error.message : String(error)}`); return; } + if (agentOutput.trim() === "") { + core.info("No agent output to process"); + core.setOutput("tools_reported", JSON.stringify(missingTools)); + core.setOutput("total_count", missingTools.length.toString()); + return; + } core.info(`Agent output length: ${agentOutput.length}`); let validatedOutput; try { diff --git a/.github/workflows/brave.lock.yml b/.github/workflows/brave.lock.yml index d14feb9c6e1..7c5a1f94d3d 100644 --- a/.github/workflows/brave.lock.yml +++ b/.github/workflows/brave.lock.yml @@ -4506,6 +4506,12 @@ jobs: core.setFailed(`Error reading agent output file: ${error instanceof Error ? error.message : String(error)}`); return; } + if (agentOutput.trim() === "") { + core.info("No agent output to process"); + core.setOutput("tools_reported", JSON.stringify(missingTools)); + core.setOutput("total_count", missingTools.length.toString()); + return; + } core.info(`Agent output length: ${agentOutput.length}`); let validatedOutput; try { diff --git a/.github/workflows/changeset-generator.lock.yml b/.github/workflows/changeset-generator.lock.yml index 5d5687a26fb..b081567c148 100644 --- a/.github/workflows/changeset-generator.lock.yml +++ b/.github/workflows/changeset-generator.lock.yml @@ -3697,6 +3697,12 @@ jobs: core.setFailed(`Error reading agent output file: ${error instanceof Error ? error.message : String(error)}`); return; } + if (agentOutput.trim() === "") { + core.info("No agent output to process"); + core.setOutput("tools_reported", JSON.stringify(missingTools)); + core.setOutput("total_count", missingTools.length.toString()); + return; + } core.info(`Agent output length: ${agentOutput.length}`); let validatedOutput; try { @@ -3915,6 +3921,10 @@ jobs: core.setFailed(`Error reading agent output file: ${error instanceof Error ? error.message : String(error)}`); return; } + if (outputContent.trim() === "") { + core.info("Agent output content is empty"); + return; + } const target = process.env.GITHUB_AW_PUSH_TARGET || "triggering"; const ifNoChanges = process.env.GITHUB_AW_PUSH_IF_NO_CHANGES || "warn"; if (!fs.existsSync("/tmp/gh-aw/aw.patch")) { diff --git a/.github/workflows/ci-doctor.lock.yml b/.github/workflows/ci-doctor.lock.yml index cb8a749b37c..f5f570fd7f2 100644 --- a/.github/workflows/ci-doctor.lock.yml +++ b/.github/workflows/ci-doctor.lock.yml @@ -4219,6 +4219,12 @@ jobs: core.setFailed(`Error reading agent output file: ${error instanceof Error ? error.message : String(error)}`); return; } + if (agentOutput.trim() === "") { + core.info("No agent output to process"); + core.setOutput("tools_reported", JSON.stringify(missingTools)); + core.setOutput("total_count", missingTools.length.toString()); + return; + } core.info(`Agent output length: ${agentOutput.length}`); let validatedOutput; try { diff --git a/.github/workflows/cli-version-checker.lock.yml b/.github/workflows/cli-version-checker.lock.yml index c83b24fb880..3a1445f0dce 100644 --- a/.github/workflows/cli-version-checker.lock.yml +++ b/.github/workflows/cli-version-checker.lock.yml @@ -3644,6 +3644,12 @@ jobs: core.setFailed(`Error reading agent output file: ${error instanceof Error ? error.message : String(error)}`); return; } + if (agentOutput.trim() === "") { + core.info("No agent output to process"); + core.setOutput("tools_reported", JSON.stringify(missingTools)); + core.setOutput("total_count", missingTools.length.toString()); + return; + } core.info(`Agent output length: ${agentOutput.length}`); let validatedOutput; try { diff --git a/.github/workflows/daily-doc-updater.lock.yml b/.github/workflows/daily-doc-updater.lock.yml index 3baad9540a1..71c823cabf9 100644 --- a/.github/workflows/daily-doc-updater.lock.yml +++ b/.github/workflows/daily-doc-updater.lock.yml @@ -3786,6 +3786,12 @@ jobs: core.setFailed(`Error reading agent output file: ${error instanceof Error ? error.message : String(error)}`); return; } + if (agentOutput.trim() === "") { + core.info("No agent output to process"); + core.setOutput("tools_reported", JSON.stringify(missingTools)); + core.setOutput("total_count", missingTools.length.toString()); + return; + } core.info(`Agent output length: ${agentOutput.length}`); let validatedOutput; try { diff --git a/.github/workflows/daily-news.lock.yml b/.github/workflows/daily-news.lock.yml index a875075770d..d27aff390b2 100644 --- a/.github/workflows/daily-news.lock.yml +++ b/.github/workflows/daily-news.lock.yml @@ -3751,6 +3751,12 @@ jobs: core.setFailed(`Error reading agent output file: ${error instanceof Error ? error.message : String(error)}`); return; } + if (agentOutput.trim() === "") { + core.info("No agent output to process"); + core.setOutput("tools_reported", JSON.stringify(missingTools)); + core.setOutput("total_count", missingTools.length.toString()); + return; + } core.info(`Agent output length: ${agentOutput.length}`); let validatedOutput; try { diff --git a/.github/workflows/dev.lock.yml b/.github/workflows/dev.lock.yml index efd787f5bb2..402b6b4758a 100644 --- a/.github/workflows/dev.lock.yml +++ b/.github/workflows/dev.lock.yml @@ -4067,6 +4067,12 @@ jobs: core.setFailed(`Error reading agent output file: ${error instanceof Error ? error.message : String(error)}`); return; } + if (agentOutput.trim() === "") { + core.info("No agent output to process"); + core.setOutput("tools_reported", JSON.stringify(missingTools)); + core.setOutput("total_count", missingTools.length.toString()); + return; + } core.info(`Agent output length: ${agentOutput.length}`); let validatedOutput; try { diff --git a/.github/workflows/duplicate-code-detector.lock.yml b/.github/workflows/duplicate-code-detector.lock.yml index ad898667013..0b39a013766 100644 --- a/.github/workflows/duplicate-code-detector.lock.yml +++ b/.github/workflows/duplicate-code-detector.lock.yml @@ -3332,6 +3332,12 @@ jobs: core.setFailed(`Error reading agent output file: ${error instanceof Error ? error.message : String(error)}`); return; } + if (agentOutput.trim() === "") { + core.info("No agent output to process"); + core.setOutput("tools_reported", JSON.stringify(missingTools)); + core.setOutput("total_count", missingTools.length.toString()); + return; + } core.info(`Agent output length: ${agentOutput.length}`); let validatedOutput; try { diff --git a/.github/workflows/example-workflow-analyzer.lock.yml b/.github/workflows/example-workflow-analyzer.lock.yml index 55faa476d27..2333da16dc8 100644 --- a/.github/workflows/example-workflow-analyzer.lock.yml +++ b/.github/workflows/example-workflow-analyzer.lock.yml @@ -3308,6 +3308,12 @@ jobs: core.setFailed(`Error reading agent output file: ${error instanceof Error ? error.message : String(error)}`); return; } + if (agentOutput.trim() === "") { + core.info("No agent output to process"); + core.setOutput("tools_reported", JSON.stringify(missingTools)); + core.setOutput("total_count", missingTools.length.toString()); + return; + } core.info(`Agent output length: ${agentOutput.length}`); let validatedOutput; try { diff --git a/.github/workflows/github-mcp-tools-report.lock.yml b/.github/workflows/github-mcp-tools-report.lock.yml index 94a571b00b0..4f25f2d58c6 100644 --- a/.github/workflows/github-mcp-tools-report.lock.yml +++ b/.github/workflows/github-mcp-tools-report.lock.yml @@ -4223,6 +4223,12 @@ jobs: core.setFailed(`Error reading agent output file: ${error instanceof Error ? error.message : String(error)}`); return; } + if (agentOutput.trim() === "") { + core.info("No agent output to process"); + core.setOutput("tools_reported", JSON.stringify(missingTools)); + core.setOutput("total_count", missingTools.length.toString()); + return; + } core.info(`Agent output length: ${agentOutput.length}`); let validatedOutput; try { diff --git a/.github/workflows/go-pattern-detector.lock.yml b/.github/workflows/go-pattern-detector.lock.yml index b45d71d1c43..f211aeb8729 100644 --- a/.github/workflows/go-pattern-detector.lock.yml +++ b/.github/workflows/go-pattern-detector.lock.yml @@ -3425,6 +3425,12 @@ jobs: core.setFailed(`Error reading agent output file: ${error instanceof Error ? error.message : String(error)}`); return; } + if (agentOutput.trim() === "") { + core.info("No agent output to process"); + core.setOutput("tools_reported", JSON.stringify(missingTools)); + core.setOutput("total_count", missingTools.length.toString()); + return; + } core.info(`Agent output length: ${agentOutput.length}`); let validatedOutput; try { diff --git a/.github/workflows/issue-classifier.lock.yml b/.github/workflows/issue-classifier.lock.yml index 763dfa4dcd7..079be78ae04 100644 --- a/.github/workflows/issue-classifier.lock.yml +++ b/.github/workflows/issue-classifier.lock.yml @@ -2850,6 +2850,12 @@ jobs: core.setFailed(`Error reading agent output file: ${error instanceof Error ? error.message : String(error)}`); return; } + if (agentOutput.trim() === "") { + core.info("No agent output to process"); + core.setOutput("tools_reported", JSON.stringify(missingTools)); + core.setOutput("total_count", missingTools.length.toString()); + return; + } core.info(`Agent output length: ${agentOutput.length}`); let validatedOutput; try { diff --git a/.github/workflows/lockfile-stats.lock.yml b/.github/workflows/lockfile-stats.lock.yml index 5017695d8ac..812bbae8f96 100644 --- a/.github/workflows/lockfile-stats.lock.yml +++ b/.github/workflows/lockfile-stats.lock.yml @@ -3608,6 +3608,12 @@ jobs: core.setFailed(`Error reading agent output file: ${error instanceof Error ? error.message : String(error)}`); return; } + if (agentOutput.trim() === "") { + core.info("No agent output to process"); + core.setOutput("tools_reported", JSON.stringify(missingTools)); + core.setOutput("total_count", missingTools.length.toString()); + return; + } core.info(`Agent output length: ${agentOutput.length}`); let validatedOutput; try { diff --git a/.github/workflows/mcp-inspector.lock.yml b/.github/workflows/mcp-inspector.lock.yml index e698b877cb5..5fcbb2d0e19 100644 --- a/.github/workflows/mcp-inspector.lock.yml +++ b/.github/workflows/mcp-inspector.lock.yml @@ -4633,6 +4633,12 @@ jobs: core.setFailed(`Error reading agent output file: ${error instanceof Error ? error.message : String(error)}`); return; } + if (agentOutput.trim() === "") { + core.info("No agent output to process"); + core.setOutput("tools_reported", JSON.stringify(missingTools)); + core.setOutput("total_count", missingTools.length.toString()); + return; + } core.info(`Agent output length: ${agentOutput.length}`); let validatedOutput; try { diff --git a/.github/workflows/pdf-summary.lock.yml b/.github/workflows/pdf-summary.lock.yml index a17605f2e52..d22c1bc390e 100644 --- a/.github/workflows/pdf-summary.lock.yml +++ b/.github/workflows/pdf-summary.lock.yml @@ -4456,6 +4456,12 @@ jobs: core.setFailed(`Error reading agent output file: ${error instanceof Error ? error.message : String(error)}`); return; } + if (agentOutput.trim() === "") { + core.info("No agent output to process"); + core.setOutput("tools_reported", JSON.stringify(missingTools)); + core.setOutput("total_count", missingTools.length.toString()); + return; + } core.info(`Agent output length: ${agentOutput.length}`); let validatedOutput; try { diff --git a/.github/workflows/plan.lock.yml b/.github/workflows/plan.lock.yml index ec1f80f2a10..ff5dfc6d0a9 100644 --- a/.github/workflows/plan.lock.yml +++ b/.github/workflows/plan.lock.yml @@ -4310,6 +4310,12 @@ jobs: core.setFailed(`Error reading agent output file: ${error instanceof Error ? error.message : String(error)}`); return; } + if (agentOutput.trim() === "") { + core.info("No agent output to process"); + core.setOutput("tools_reported", JSON.stringify(missingTools)); + core.setOutput("total_count", missingTools.length.toString()); + return; + } core.info(`Agent output length: ${agentOutput.length}`); let validatedOutput; try { diff --git a/.github/workflows/poem-bot.lock.yml b/.github/workflows/poem-bot.lock.yml index ef78e8469e1..0b37d3ca03d 100644 --- a/.github/workflows/poem-bot.lock.yml +++ b/.github/workflows/poem-bot.lock.yml @@ -5846,6 +5846,12 @@ jobs: core.setFailed(`Error reading agent output file: ${error instanceof Error ? error.message : String(error)}`); return; } + if (agentOutput.trim() === "") { + core.info("No agent output to process"); + core.setOutput("tools_reported", JSON.stringify(missingTools)); + core.setOutput("total_count", missingTools.length.toString()); + return; + } core.info(`Agent output length: ${agentOutput.length}`); let validatedOutput; try { @@ -6066,6 +6072,10 @@ jobs: core.setFailed(`Error reading agent output file: ${error instanceof Error ? error.message : String(error)}`); return; } + if (outputContent.trim() === "") { + core.info("Agent output content is empty"); + return; + } const target = process.env.GITHUB_AW_PUSH_TARGET || "triggering"; const ifNoChanges = process.env.GITHUB_AW_PUSH_IF_NO_CHANGES || "warn"; if (!fs.existsSync("/tmp/gh-aw/aw.patch")) { diff --git a/.github/workflows/q.lock.yml b/.github/workflows/q.lock.yml index 3898c196c8d..debfd131967 100644 --- a/.github/workflows/q.lock.yml +++ b/.github/workflows/q.lock.yml @@ -5305,6 +5305,12 @@ jobs: core.setFailed(`Error reading agent output file: ${error instanceof Error ? error.message : String(error)}`); return; } + if (agentOutput.trim() === "") { + core.info("No agent output to process"); + core.setOutput("tools_reported", JSON.stringify(missingTools)); + core.setOutput("total_count", missingTools.length.toString()); + return; + } core.info(`Agent output length: ${agentOutput.length}`); let validatedOutput; try { diff --git a/.github/workflows/repo-tree-map.lock.yml b/.github/workflows/repo-tree-map.lock.yml index 1f836fc5ba1..f2f13ebab51 100644 --- a/.github/workflows/repo-tree-map.lock.yml +++ b/.github/workflows/repo-tree-map.lock.yml @@ -3691,6 +3691,12 @@ jobs: core.setFailed(`Error reading agent output file: ${error instanceof Error ? error.message : String(error)}`); return; } + if (agentOutput.trim() === "") { + core.info("No agent output to process"); + core.setOutput("tools_reported", JSON.stringify(missingTools)); + core.setOutput("total_count", missingTools.length.toString()); + return; + } core.info(`Agent output length: ${agentOutput.length}`); let validatedOutput; try { diff --git a/.github/workflows/research.lock.yml b/.github/workflows/research.lock.yml index 7ff4dfd6e5c..d0fcb5a2b10 100644 --- a/.github/workflows/research.lock.yml +++ b/.github/workflows/research.lock.yml @@ -3667,6 +3667,12 @@ jobs: core.setFailed(`Error reading agent output file: ${error instanceof Error ? error.message : String(error)}`); return; } + if (agentOutput.trim() === "") { + core.info("No agent output to process"); + core.setOutput("tools_reported", JSON.stringify(missingTools)); + core.setOutput("total_count", missingTools.length.toString()); + return; + } core.info(`Agent output length: ${agentOutput.length}`); let validatedOutput; try { diff --git a/.github/workflows/scout.lock.yml b/.github/workflows/scout.lock.yml index 179a075eb8b..b00f9739afe 100644 --- a/.github/workflows/scout.lock.yml +++ b/.github/workflows/scout.lock.yml @@ -4869,6 +4869,12 @@ jobs: core.setFailed(`Error reading agent output file: ${error instanceof Error ? error.message : String(error)}`); return; } + if (agentOutput.trim() === "") { + core.info("No agent output to process"); + core.setOutput("tools_reported", JSON.stringify(missingTools)); + core.setOutput("total_count", missingTools.length.toString()); + return; + } core.info(`Agent output length: ${agentOutput.length}`); let validatedOutput; try { diff --git a/.github/workflows/security-fix-pr.lock.yml b/.github/workflows/security-fix-pr.lock.yml index a24fc1f2040..455cdaf95a7 100644 --- a/.github/workflows/security-fix-pr.lock.yml +++ b/.github/workflows/security-fix-pr.lock.yml @@ -3731,6 +3731,12 @@ jobs: core.setFailed(`Error reading agent output file: ${error instanceof Error ? error.message : String(error)}`); return; } + if (agentOutput.trim() === "") { + core.info("No agent output to process"); + core.setOutput("tools_reported", JSON.stringify(missingTools)); + core.setOutput("total_count", missingTools.length.toString()); + return; + } core.info(`Agent output length: ${agentOutput.length}`); let validatedOutput; try { diff --git a/.github/workflows/smoke-claude.lock.yml b/.github/workflows/smoke-claude.lock.yml index fc96a99891a..5e0261cc7be 100644 --- a/.github/workflows/smoke-claude.lock.yml +++ b/.github/workflows/smoke-claude.lock.yml @@ -3266,6 +3266,12 @@ jobs: core.setFailed(`Error reading agent output file: ${error instanceof Error ? error.message : String(error)}`); return; } + if (agentOutput.trim() === "") { + core.info("No agent output to process"); + core.setOutput("tools_reported", JSON.stringify(missingTools)); + core.setOutput("total_count", missingTools.length.toString()); + return; + } core.info(`Agent output length: ${agentOutput.length}`); let validatedOutput; try { diff --git a/.github/workflows/smoke-codex.lock.yml b/.github/workflows/smoke-codex.lock.yml index 50d5ffee189..e565b3470b2 100644 --- a/.github/workflows/smoke-codex.lock.yml +++ b/.github/workflows/smoke-codex.lock.yml @@ -3078,6 +3078,12 @@ jobs: core.setFailed(`Error reading agent output file: ${error instanceof Error ? error.message : String(error)}`); return; } + if (agentOutput.trim() === "") { + core.info("No agent output to process"); + core.setOutput("tools_reported", JSON.stringify(missingTools)); + core.setOutput("total_count", missingTools.length.toString()); + return; + } core.info(`Agent output length: ${agentOutput.length}`); let validatedOutput; try { diff --git a/.github/workflows/smoke-copilot.lock.yml b/.github/workflows/smoke-copilot.lock.yml index 41373529a99..e355da44a33 100644 --- a/.github/workflows/smoke-copilot.lock.yml +++ b/.github/workflows/smoke-copilot.lock.yml @@ -3668,6 +3668,12 @@ jobs: core.setFailed(`Error reading agent output file: ${error instanceof Error ? error.message : String(error)}`); return; } + if (agentOutput.trim() === "") { + core.info("No agent output to process"); + core.setOutput("tools_reported", JSON.stringify(missingTools)); + core.setOutput("total_count", missingTools.length.toString()); + return; + } core.info(`Agent output length: ${agentOutput.length}`); let validatedOutput; try { diff --git a/.github/workflows/smoke-genaiscript.lock.yml b/.github/workflows/smoke-genaiscript.lock.yml index 4d0749fbee8..a58ece4d568 100644 --- a/.github/workflows/smoke-genaiscript.lock.yml +++ b/.github/workflows/smoke-genaiscript.lock.yml @@ -2396,6 +2396,12 @@ jobs: core.setFailed(`Error reading agent output file: ${error instanceof Error ? error.message : String(error)}`); return; } + if (agentOutput.trim() === "") { + core.info("No agent output to process"); + core.setOutput("tools_reported", JSON.stringify(missingTools)); + core.setOutput("total_count", missingTools.length.toString()); + return; + } core.info(`Agent output length: ${agentOutput.length}`); let validatedOutput; try { diff --git a/.github/workflows/smoke-opencode.lock.yml b/.github/workflows/smoke-opencode.lock.yml index 04fbb787e05..e5192b41cd8 100644 --- a/.github/workflows/smoke-opencode.lock.yml +++ b/.github/workflows/smoke-opencode.lock.yml @@ -2364,6 +2364,12 @@ jobs: core.setFailed(`Error reading agent output file: ${error instanceof Error ? error.message : String(error)}`); return; } + if (agentOutput.trim() === "") { + core.info("No agent output to process"); + core.setOutput("tools_reported", JSON.stringify(missingTools)); + core.setOutput("total_count", missingTools.length.toString()); + return; + } core.info(`Agent output length: ${agentOutput.length}`); let validatedOutput; try { diff --git a/.github/workflows/technical-doc-writer.lock.yml b/.github/workflows/technical-doc-writer.lock.yml index d403a13e2e4..979648c59b0 100644 --- a/.github/workflows/technical-doc-writer.lock.yml +++ b/.github/workflows/technical-doc-writer.lock.yml @@ -4157,6 +4157,12 @@ jobs: core.setFailed(`Error reading agent output file: ${error instanceof Error ? error.message : String(error)}`); return; } + if (agentOutput.trim() === "") { + core.info("No agent output to process"); + core.setOutput("tools_reported", JSON.stringify(missingTools)); + core.setOutput("total_count", missingTools.length.toString()); + return; + } core.info(`Agent output length: ${agentOutput.length}`); let validatedOutput; try { diff --git a/.github/workflows/tidy.lock.yml b/.github/workflows/tidy.lock.yml index bd382e46fca..99c5202a9d7 100644 --- a/.github/workflows/tidy.lock.yml +++ b/.github/workflows/tidy.lock.yml @@ -4437,6 +4437,12 @@ jobs: core.setFailed(`Error reading agent output file: ${error instanceof Error ? error.message : String(error)}`); return; } + if (agentOutput.trim() === "") { + core.info("No agent output to process"); + core.setOutput("tools_reported", JSON.stringify(missingTools)); + core.setOutput("total_count", missingTools.length.toString()); + return; + } core.info(`Agent output length: ${agentOutput.length}`); let validatedOutput; try { @@ -4657,6 +4663,10 @@ jobs: core.setFailed(`Error reading agent output file: ${error instanceof Error ? error.message : String(error)}`); return; } + if (outputContent.trim() === "") { + core.info("Agent output content is empty"); + return; + } const target = process.env.GITHUB_AW_PUSH_TARGET || "triggering"; const ifNoChanges = process.env.GITHUB_AW_PUSH_IF_NO_CHANGES || "warn"; if (!fs.existsSync("/tmp/gh-aw/aw.patch")) { diff --git a/.github/workflows/unbloat-docs.lock.yml b/.github/workflows/unbloat-docs.lock.yml index ff5029373c0..9a6a763d481 100644 --- a/.github/workflows/unbloat-docs.lock.yml +++ b/.github/workflows/unbloat-docs.lock.yml @@ -4630,6 +4630,12 @@ jobs: core.setFailed(`Error reading agent output file: ${error instanceof Error ? error.message : String(error)}`); return; } + if (agentOutput.trim() === "") { + core.info("No agent output to process"); + core.setOutput("tools_reported", JSON.stringify(missingTools)); + core.setOutput("total_count", missingTools.length.toString()); + return; + } core.info(`Agent output length: ${agentOutput.length}`); let validatedOutput; try {