From 392b039711c5c9af9afa5aa1c7aa5ec3b928c843 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 11 Apr 2026 19:55:17 +0000 Subject: [PATCH 1/3] Initial plan From 589ac38b055ac7af461921e643505b72946ade6a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 11 Apr 2026 20:24:20 +0000 Subject: [PATCH 2/3] fix: prevent ENOBUFS on large diffs in execGitSync by setting maxBuffer to 100MB Set maxBuffer: 100 * 1024 * 1024 (100 MB) as the default in execGitSync's spawnSync call, preventing ENOBUFS when git format-patch produces output exceeding Node.js's default 1 MB buffer limit. Also adds explicit ENOBUFS detection to surface an actionable error message instead of the misleading "No changes to commit" fallback. Closes #1612 Agent-Logs-Url: https://github.com/github/gh-aw/sessions/38d92d89-2d17-4599-b7fe-7b38765cfc33 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- .changeset/patch-fix-create-pr-enobufs.md | 12 ++++++++++++ actions/setup/js/git_helpers.cjs | 10 ++++++++++ actions/setup/js/git_helpers.test.cjs | 9 +++++++++ 3 files changed, 31 insertions(+) create mode 100644 .changeset/patch-fix-create-pr-enobufs.md diff --git a/.changeset/patch-fix-create-pr-enobufs.md b/.changeset/patch-fix-create-pr-enobufs.md new file mode 100644 index 00000000000..e3e006f3c17 --- /dev/null +++ b/.changeset/patch-fix-create-pr-enobufs.md @@ -0,0 +1,12 @@ +--- +"gh-aw": patch +--- + +Fixed `create_pull_request` failing with `spawnSync git ENOBUFS` on large diffs (e.g. 47+ changed files). + +The `execGitSync` helper in `git_helpers.cjs` used Node.js `spawnSync` without an explicit `maxBuffer`, defaulting to ~1 MB. When `git format-patch --stdout` produced output exceeding that limit, all patch generation strategies silently failed with a misleading "No changes to commit" error. + +The fix: +- Set `maxBuffer: 100 * 1024 * 1024` (100 MB) as the default in `execGitSync`, matching the `max_patch_size` headroom and consistent with other handlers in the codebase (e.g. MCP handlers use 10 MB). +- Detect `ENOBUFS` errors and throw an actionable error message that surfaces the real cause instead of the generic "no commits found" fallback. +- Callers can still override `maxBuffer` via the options spread. diff --git a/actions/setup/js/git_helpers.cjs b/actions/setup/js/git_helpers.cjs index 84bf2b65630..3ae9dcc8330 100644 --- a/actions/setup/js/git_helpers.cjs +++ b/actions/setup/js/git_helpers.cjs @@ -66,10 +66,20 @@ function execGitSync(args, options = {}) { const result = spawnSync("git", args, { encoding: "utf8", + maxBuffer: 100 * 1024 * 1024, // 100 MB — prevents ENOBUFS on large diffs (e.g. git format-patch) ...spawnOptions, }); if (result.error) { + // Detect ENOBUFS (buffer overflow) and provide a more actionable message + if (result.error.code === "ENOBUFS") { + const bufferError = new Error( + `${ERR_SYSTEM}: Git command output exceeded buffer limit (ENOBUFS). ` + `The output from '${args[0]}' is too large for the configured maxBuffer. ` + `Consider reducing the diff size or increasing maxBuffer.` + ); + bufferError.code = "ENOBUFS"; + core.error(`Git command buffer overflow: ${gitCommand}`); + throw bufferError; + } // Spawn-level errors (e.g. ENOENT, EACCES) are always unexpected — log // via core.error regardless of suppressLogs. core.error(`Git command failed with error: ${result.error.message}`); diff --git a/actions/setup/js/git_helpers.test.cjs b/actions/setup/js/git_helpers.test.cjs index 04d35c76e20..63f5d886a06 100644 --- a/actions/setup/js/git_helpers.test.cjs +++ b/actions/setup/js/git_helpers.test.cjs @@ -80,6 +80,15 @@ describe("git_helpers.cjs", () => { expect(result).toContain("git version"); }); + it("should throw actionable ENOBUFS error when maxBuffer is exceeded", async () => { + const { execGitSync } = await import("./git_helpers.cjs"); + + // Use a tiny maxBuffer to trigger ENOBUFS on any git output + expect(() => { + execGitSync(["--version"], { maxBuffer: 1 }); + }).toThrow(/ENOBUFS|buffer limit/i); + }); + it("should return stdout from successful commands", async () => { const { execGitSync } = await import("./git_helpers.cjs"); From fdc7edd295d888c6dc4464e986ce927dfc65554a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 11 Apr 2026 20:25:21 +0000 Subject: [PATCH 3/3] style: use single template literal for ENOBUFS error message Agent-Logs-Url: https://github.com/github/gh-aw/sessions/38d92d89-2d17-4599-b7fe-7b38765cfc33 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- actions/setup/js/git_helpers.cjs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/actions/setup/js/git_helpers.cjs b/actions/setup/js/git_helpers.cjs index 3ae9dcc8330..c7013a7bcb5 100644 --- a/actions/setup/js/git_helpers.cjs +++ b/actions/setup/js/git_helpers.cjs @@ -73,9 +73,7 @@ function execGitSync(args, options = {}) { if (result.error) { // Detect ENOBUFS (buffer overflow) and provide a more actionable message if (result.error.code === "ENOBUFS") { - const bufferError = new Error( - `${ERR_SYSTEM}: Git command output exceeded buffer limit (ENOBUFS). ` + `The output from '${args[0]}' is too large for the configured maxBuffer. ` + `Consider reducing the diff size or increasing maxBuffer.` - ); + const bufferError = new Error(`${ERR_SYSTEM}: Git command output exceeded buffer limit (ENOBUFS). The output from '${args[0]}' is too large for the configured maxBuffer. Consider reducing the diff size or increasing maxBuffer.`); bufferError.code = "ENOBUFS"; core.error(`Git command buffer overflow: ${gitCommand}`); throw bufferError;