Skip to content

Commit 4316276

Browse files
committed
Fix emitInfrastructureIncomplete call to fs.appendFileSync
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
1 parent 798da49 commit 4316276

1 file changed

Lines changed: 27 additions & 1 deletion

File tree

actions/setup/js/copilot_driver.cjs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,32 @@ function appendSafeOutputLine(appendFileSync, safeOutputsPath, payload) {
145145
appendFileSync(safeOutputsPath, payload + "\n", "utf8");
146146
}
147147

148+
/**
149+
* Wrapper for fs.appendFileSync
150+
* @param {string} path
151+
* @param {string} data
152+
* @param {string} encoding
153+
*/
154+
function fs_appendFileSync_wrapper(path, data, encoding) {
155+
let params = {};
156+
switch (encoding) {
157+
case "ascii":
158+
case "utf8":
159+
case "utf-8":
160+
case "utf16le":
161+
case "utf-16le":
162+
case "ucs2":
163+
case "ucs-2":
164+
case "base64":
165+
case "base64url":
166+
case "latin1":
167+
case "binary":
168+
case "hex":
169+
params = { encoding: encoding };
170+
}
171+
fs.appendFileSync(path, data, params);
172+
}
173+
148174
/**
149175
* Append a structured report_incomplete signal when infrastructure failures prevent completion.
150176
* This allows downstream failure handling to classify transient infrastructure errors explicitly.
@@ -157,7 +183,7 @@ function appendSafeOutputLine(appendFileSync, safeOutputsPath, payload) {
157183
*/
158184
function emitInfrastructureIncomplete(details, options) {
159185
const safeOutputsPath = options && typeof options.safeOutputsPath === "string" ? options.safeOutputsPath : process.env.GH_AW_SAFE_OUTPUTS || "";
160-
const appendFileSync = options && options.appendFileSync ? options.appendFileSync : fs.appendFileSync;
186+
const appendFileSync = options && options.appendFileSync ? options.appendFileSync : fs_appendFileSync_wrapper;
161187
const logger = options && options.logger ? options.logger : log;
162188

163189
if (!safeOutputsPath) {

0 commit comments

Comments
 (0)