From f8556088acb3ab977c87576f0c973f65b6bf26d7 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
 <41898282+github-actions[bot]@users.noreply.github.com>
Date: Thu, 23 Jul 2026 04:57:49 +0000
Subject: [PATCH 1/2] jsweep: clean write_large_content_to_file.cjs

- Remove misleading triple-slash reference to @actions/github-script types
  (file is a pure Node.js CJS module, not a github-script context)
- Use err.message instead of String(err) in error messages for cleaner output
- Add 2 new tests covering error paths (mkdir failure, writeFile failure)
  bringing total test count from 20 to 22

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
 .../setup/js/write_large_content_to_file.cjs  |  5 ++--
 .../js/write_large_content_to_file.test.cjs   | 30 +++++++++++++++++++
 2 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/actions/setup/js/write_large_content_to_file.cjs b/actions/setup/js/write_large_content_to_file.cjs
index f8e6a6aec9c..d386a9326c7 100644
--- a/actions/setup/js/write_large_content_to_file.cjs
+++ b/actions/setup/js/write_large_content_to_file.cjs
@@ -1,5 +1,4 @@
 // @ts-check
-/// <reference types="@actions/github-script" />
 
 const fs = require("fs");
 const path = require("path");
@@ -18,7 +17,7 @@ function writeLargeContentToFile(content) {
   try {
     fs.mkdirSync(logsDir, { recursive: true });
   } catch (err) {
-    throw new Error(`Failed to create directory ${logsDir}: ${String(err)}`, { cause: err });
+    throw new Error(`Failed to create directory ${logsDir}: ${err.message}`, { cause: err });
   }
 
   // Generate SHA256 hash of content
@@ -31,7 +30,7 @@ function writeLargeContentToFile(content) {
   try {
     fs.writeFileSync(filepath, content, "utf8");
   } catch (err) {
-    throw new Error(`Failed to write file ${filepath}: ${String(err)}`, { cause: err });
+    throw new Error(`Failed to write file ${filepath}: ${err.message}`, { cause: err });
   }
 
   const description = generateCompactSchema(content);
diff --git a/actions/setup/js/write_large_content_to_file.test.cjs b/actions/setup/js/write_large_content_to_file.test.cjs
index 9dc9e3c7c6a..4c1f88bd074 100644
--- a/actions/setup/js/write_large_content_to_file.test.cjs
+++ b/actions/setup/js/write_large_content_to_file.test.cjs
@@ -228,4 +228,34 @@ describe("writeLargeContentToFile", () => {
     expect(result).toHaveProperty("description");
     expect(Object.keys(result)).toHaveLength(2);
   });
+
+  it("should include err.message (not String(err)) in directory creation error", async () => {
+    const { writeLargeContentToFile } = await import("./write_large_content_to_file.cjs");
+    const origMkdirSync = fs.mkdirSync;
+    // @ts-ignore
+    fs.mkdirSync = () => {
+      throw new Error("permission denied");
+    };
+    try {
+      expect(() => writeLargeContentToFile("{}")).toThrow("Failed to create directory");
+      expect(() => writeLargeContentToFile("{}")).toThrow("permission denied");
+    } finally {
+      fs.mkdirSync = origMkdirSync;
+    }
+  });
+
+  it("should include err.message (not String(err)) in file write error", async () => {
+    const { writeLargeContentToFile } = await import("./write_large_content_to_file.cjs");
+    const origWriteFileSync = fs.writeFileSync;
+    // @ts-ignore
+    fs.writeFileSync = () => {
+      throw new Error("disk full");
+    };
+    try {
+      expect(() => writeLargeContentToFile("{}")).toThrow("Failed to write file");
+      expect(() => writeLargeContentToFile("{}")).toThrow("disk full");
+    } finally {
+      fs.writeFileSync = origWriteFileSync;
+    }
+  });
 });

From 55d43cd8d8871ceae6801c186d0597ac082239dd Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Thu, 23 Jul 2026 05:47:13 +0000
Subject: [PATCH 2/2] test(js): assert full error message shape in
 write_large_content_to_file tests

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
---
 .../setup/js/write_large_content_to_file.test.cjs    | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/actions/setup/js/write_large_content_to_file.test.cjs b/actions/setup/js/write_large_content_to_file.test.cjs
index 4c1f88bd074..bd954d6b9be 100644
--- a/actions/setup/js/write_large_content_to_file.test.cjs
+++ b/actions/setup/js/write_large_content_to_file.test.cjs
@@ -237,8 +237,10 @@ describe("writeLargeContentToFile", () => {
       throw new Error("permission denied");
     };
     try {
-      expect(() => writeLargeContentToFile("{}")).toThrow("Failed to create directory");
-      expect(() => writeLargeContentToFile("{}")).toThrow("permission denied");
+      const fn = () => writeLargeContentToFile("{}");
+      expect(fn).toThrow("Failed to create directory");
+      expect(fn).toThrow(": permission denied");
+      expect(fn).not.toThrow(": Error: permission denied");
     } finally {
       fs.mkdirSync = origMkdirSync;
     }
@@ -252,8 +254,10 @@ describe("writeLargeContentToFile", () => {
       throw new Error("disk full");
     };
     try {
-      expect(() => writeLargeContentToFile("{}")).toThrow("Failed to write file");
-      expect(() => writeLargeContentToFile("{}")).toThrow("disk full");
+      const fn = () => writeLargeContentToFile("{}");
+      expect(fn).toThrow("Failed to write file");
+      expect(fn).toThrow(": disk full");
+      expect(fn).not.toThrow(": Error: disk full");
     } finally {
       fs.writeFileSync = origWriteFileSync;
     }
