From e44294b2d491740a894b6f4a56a3370ac9ef726c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 1 Jul 2026 06:35:54 +0000 Subject: [PATCH 1/6] Improve code push error file rendering Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- actions/setup/js/handle_agent_failure.cjs | 28 +++++++++++++++++-- .../setup/js/handle_agent_failure.test.cjs | 14 ++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/actions/setup/js/handle_agent_failure.cjs b/actions/setup/js/handle_agent_failure.cjs index 2891c32955a..baf76d803e4 100644 --- a/actions/setup/js/handle_agent_failure.cjs +++ b/actions/setup/js/handle_agent_failure.cjs @@ -4,7 +4,7 @@ const { getErrorMessage } = require("./error_helpers.cjs"); const { sanitizeContent } = require("./sanitize_content.cjs"); const { getDetectionCautionAlert, getFooterAgentFailureIssueMessage, getFooterAgentFailureCommentMessage, generateXMLMarker } = require("./messages.cjs"); -const { renderTemplate, renderTemplateFromFile, getPromptPath } = require("./messages_core.cjs"); +const { renderTemplate, renderTemplateFromFile, getPromptPath, renderFilesList } = require("./messages_core.cjs"); const { getCurrentBranch } = require("./get_current_branch.cjs"); const { createExpirationLine, extractExpirationDate, generateFooterWithExpiration } = require("./ephemerals.cjs"); const { MAX_SUB_ISSUES, getSubIssueCount } = require("./sub_issue_helpers.cjs"); @@ -77,6 +77,30 @@ function buildWarningAlertLine(title, message) { return `\n> [!WARNING]\n> **${title}**: ${message}\n`; } +/** + * Render an allowed-files error using progressive disclosure for the file list. + * @param {string} type + * @param {string} error + * @returns {string|null} + */ +function renderAllowedFilesError(type, error) { + const match = error.match(/^(.*outside the allowed-files list) \(([^)]+)\)\. (Add the files to the allowed-files configuration field or remove them from the (?:patch|bundle)\.)$/); + if (!match) { + return null; + } + + const summary = match[1]; + const files = match[2] + .split(",") + .map(file => file.trim()) + .filter(Boolean); + const remediation = match[3]; + const fileCount = files.length; + const fileLabel = fileCount === 1 ? "file" : "files"; + + return `- \`${type}\`: ${summary}. ${remediation}\n` + `\n
\nShow ${fileCount} blocked ${fileLabel}\n\n` + `${renderFilesList(files)}\n` + `\n
\n`; +} + /** * Render a prompt template from runtime prompts. * @param {string} templateName @@ -947,7 +971,7 @@ gh pr create --head aw/manual-apply } context += "\n**Code Push Errors:**\n"; for (const { type, error } of otherErrors) { - context += `- \`${type}\`: ${error}\n`; + context += renderAllowedFilesError(type, error) || `- \`${type}\`: ${error}\n`; } context += "\n"; } else if (manifestErrors.length > 0 || patchSizeErrors.length > 0 || patchApplyErrors.length > 0) { diff --git a/actions/setup/js/handle_agent_failure.test.cjs b/actions/setup/js/handle_agent_failure.test.cjs index e167eed7066..983ed66c444 100644 --- a/actions/setup/js/handle_agent_failure.test.cjs +++ b/actions/setup/js/handle_agent_failure.test.cjs @@ -1457,6 +1457,20 @@ describe("handle_agent_failure", () => { expect(result).not.toContain("Protected Files"); }); + it("renders allowed-files errors with progressive disclosure", () => { + const errors = + "create_pull_request:Cannot create pull request: patch modifies files outside the allowed-files list " + + "(pkg/workflow/codex_engine.go, pkg/workflow/codex_mcp.go, pkg/workflow/compiler_yaml.go). " + + "Add the files to the allowed-files configuration field or remove them from the patch."; + const result = buildCodePushFailureContext(errors); + expect(result).toContain("Code Push Failed"); + expect(result).toContain("outside the allowed-files list. Add the files to the allowed-files configuration field or remove them from the patch."); + expect(result).toContain("
"); + expect(result).toContain("Show 3 blocked files"); + expect(result).toContain("`pkg/workflow/codex_engine.go`, `pkg/workflow/codex_mcp.go`, `pkg/workflow/compiler_yaml.go`"); + expect(result).not.toContain("outside the allowed-files list (pkg/workflow/codex_engine.go, pkg/workflow/codex_mcp.go, pkg/workflow/compiler_yaml.go)"); + }); + it("shows both sections when protected file and non-protected-file errors are mixed", () => { const errors = [ "create_pull_request:Cannot create pull request: patch modifies package manifest files (package.json). Set allow-manifest-files: true in your workflow to allow this.", From 66eb592229024f7e9687c168084d4c9ce5491b5f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 1 Jul 2026 06:37:08 +0000 Subject: [PATCH 2/6] Refine allowed-files error rendering Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- actions/setup/js/handle_agent_failure.cjs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/actions/setup/js/handle_agent_failure.cjs b/actions/setup/js/handle_agent_failure.cjs index baf76d803e4..452bd03cd9b 100644 --- a/actions/setup/js/handle_agent_failure.cjs +++ b/actions/setup/js/handle_agent_failure.cjs @@ -42,6 +42,7 @@ const ELLIPSIS_LENGTH = ELLIPSIS.length; const ENGINE_RATE_LIMIT_429_RE = /(?:\b429\b[\s\S]{0,120}(?:too many requests|rate[\s-]*limit)|\brate_limit_(?:error|exceeded)\b|capierror:\s*429|failed to get response from the ai model[\s\S]{0,120}\b429\b|exceeded your rate limit for utility models)/i; const ENGINE_MAX_RUNS_EXCEEDED_RE = /(?:\bmax_runs_exceeded\b|\bmaximum\s+llm\s+invocations\s+exceeded\b)/i; +const ALLOWED_FILES_ERROR_RE = /^(?.*outside the allowed-files list) \((?[^)]+)\)\. (?Add the files to the allowed-files configuration field or remove them from the (?:patch|bundle)\.)$/; /** * Parse action failure issue expiration from environment. @@ -84,21 +85,21 @@ function buildWarningAlertLine(title, message) { * @returns {string|null} */ function renderAllowedFilesError(type, error) { - const match = error.match(/^(.*outside the allowed-files list) \(([^)]+)\)\. (Add the files to the allowed-files configuration field or remove them from the (?:patch|bundle)\.)$/); - if (!match) { + const match = error.match(ALLOWED_FILES_ERROR_RE); + if (!match?.groups) { return null; } - const summary = match[1]; - const files = match[2] + const summary = match.groups.summary; + const files = match.groups.files .split(",") .map(file => file.trim()) .filter(Boolean); - const remediation = match[3]; + const remediation = match.groups.remediation; const fileCount = files.length; - const fileLabel = fileCount === 1 ? "file" : "files"; + const fileWord = fileCount === 1 ? "file" : "files"; - return `- \`${type}\`: ${summary}. ${remediation}\n` + `\n
\nShow ${fileCount} blocked ${fileLabel}\n\n` + `${renderFilesList(files)}\n` + `\n
\n`; + return [`- \`${type}\`: ${summary}. ${remediation}`, "", "
", `Show ${fileCount} blocked ${fileWord}`, "", renderFilesList(files), "", "
", ""].join("\n"); } /** From a435dd47ed8f022de207f84011a84de42d4106b8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 1 Jul 2026 06:38:21 +0000 Subject: [PATCH 3/6] Polish allowed-files error formatter Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- actions/setup/js/handle_agent_failure.cjs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/actions/setup/js/handle_agent_failure.cjs b/actions/setup/js/handle_agent_failure.cjs index 452bd03cd9b..c7578e7163a 100644 --- a/actions/setup/js/handle_agent_failure.cjs +++ b/actions/setup/js/handle_agent_failure.cjs @@ -42,7 +42,9 @@ const ELLIPSIS_LENGTH = ELLIPSIS.length; const ENGINE_RATE_LIMIT_429_RE = /(?:\b429\b[\s\S]{0,120}(?:too many requests|rate[\s-]*limit)|\brate_limit_(?:error|exceeded)\b|capierror:\s*429|failed to get response from the ai model[\s\S]{0,120}\b429\b|exceeded your rate limit for utility models)/i; const ENGINE_MAX_RUNS_EXCEEDED_RE = /(?:\bmax_runs_exceeded\b|\bmaximum\s+llm\s+invocations\s+exceeded\b)/i; -const ALLOWED_FILES_ERROR_RE = /^(?.*outside the allowed-files list) \((?[^)]+)\)\. (?Add the files to the allowed-files configuration field or remove them from the (?:patch|bundle)\.)$/; +const ALLOWED_FILES_ERROR_RE = new RegExp( + ["^(?.*outside the allowed-files list) ", "\\((?[^)]+)\\)\\. ", "(?Add the files to the allowed-files configuration field or remove them from the (?:patch|bundle)\\.)$"].join("") +); /** * Parse action failure issue expiration from environment. @@ -99,7 +101,15 @@ function renderAllowedFilesError(type, error) { const fileCount = files.length; const fileWord = fileCount === 1 ? "file" : "files"; - return [`- \`${type}\`: ${summary}. ${remediation}`, "", "
", `Show ${fileCount} blocked ${fileWord}`, "", renderFilesList(files), "", "
", ""].join("\n"); + return `- \`${type}\`: ${summary}. ${remediation} + +
+Show ${fileCount} blocked ${fileWord} + +${renderFilesList(files)} + +
+`; } /** From 197f6679974b40a97745e10375bb57b0d69b493e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 1 Jul 2026 06:39:39 +0000 Subject: [PATCH 4/6] Tighten allowed-files error tests Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- actions/setup/js/handle_agent_failure.cjs | 2 +- actions/setup/js/handle_agent_failure.test.cjs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/actions/setup/js/handle_agent_failure.cjs b/actions/setup/js/handle_agent_failure.cjs index c7578e7163a..5fca327568b 100644 --- a/actions/setup/js/handle_agent_failure.cjs +++ b/actions/setup/js/handle_agent_failure.cjs @@ -96,7 +96,7 @@ function renderAllowedFilesError(type, error) { const files = match.groups.files .split(",") .map(file => file.trim()) - .filter(Boolean); + .filter(file => file !== ""); const remediation = match.groups.remediation; const fileCount = files.length; const fileWord = fileCount === 1 ? "file" : "files"; diff --git a/actions/setup/js/handle_agent_failure.test.cjs b/actions/setup/js/handle_agent_failure.test.cjs index 983ed66c444..b87d7831c0a 100644 --- a/actions/setup/js/handle_agent_failure.test.cjs +++ b/actions/setup/js/handle_agent_failure.test.cjs @@ -1467,7 +1467,9 @@ describe("handle_agent_failure", () => { expect(result).toContain("outside the allowed-files list. Add the files to the allowed-files configuration field or remove them from the patch."); expect(result).toContain("
"); expect(result).toContain("Show 3 blocked files"); - expect(result).toContain("`pkg/workflow/codex_engine.go`, `pkg/workflow/codex_mcp.go`, `pkg/workflow/compiler_yaml.go`"); + expect(result).toContain("`pkg/workflow/codex_engine.go`"); + expect(result).toContain("`pkg/workflow/codex_mcp.go`"); + expect(result).toContain("`pkg/workflow/compiler_yaml.go`"); expect(result).not.toContain("outside the allowed-files list (pkg/workflow/codex_engine.go, pkg/workflow/codex_mcp.go, pkg/workflow/compiler_yaml.go)"); }); From bc216b0ff1a99c3e7b97ce4647ecf662a0b9eea2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 1 Jul 2026 11:32:50 +0000 Subject: [PATCH 5/6] Address review feedback for allowed-files rendering Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- actions/setup/js/handle_agent_failure.cjs | 9 ++----- .../setup/js/handle_agent_failure.test.cjs | 26 +++++++++++++++++++ 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/actions/setup/js/handle_agent_failure.cjs b/actions/setup/js/handle_agent_failure.cjs index 5fca327568b..57cd3b284a2 100644 --- a/actions/setup/js/handle_agent_failure.cjs +++ b/actions/setup/js/handle_agent_failure.cjs @@ -42,9 +42,7 @@ const ELLIPSIS_LENGTH = ELLIPSIS.length; const ENGINE_RATE_LIMIT_429_RE = /(?:\b429\b[\s\S]{0,120}(?:too many requests|rate[\s-]*limit)|\brate_limit_(?:error|exceeded)\b|capierror:\s*429|failed to get response from the ai model[\s\S]{0,120}\b429\b|exceeded your rate limit for utility models)/i; const ENGINE_MAX_RUNS_EXCEEDED_RE = /(?:\bmax_runs_exceeded\b|\bmaximum\s+llm\s+invocations\s+exceeded\b)/i; -const ALLOWED_FILES_ERROR_RE = new RegExp( - ["^(?.*outside the allowed-files list) ", "\\((?[^)]+)\\)\\. ", "(?Add the files to the allowed-files configuration field or remove them from the (?:patch|bundle)\\.)$"].join("") -); +const ALLOWED_FILES_ERROR_RE = /^(?.*outside the allowed-files list) \((?.+)\)\. (?Add the files to the allowed-files configuration field or remove them from the (?:patch|bundle)\.)$/; /** * Parse action failure issue expiration from environment. @@ -93,10 +91,7 @@ function renderAllowedFilesError(type, error) { } const summary = match.groups.summary; - const files = match.groups.files - .split(",") - .map(file => file.trim()) - .filter(file => file !== ""); + const files = match.groups.files.split(",").map(file => file.trim()); const remediation = match.groups.remediation; const fileCount = files.length; const fileWord = fileCount === 1 ? "file" : "files"; diff --git a/actions/setup/js/handle_agent_failure.test.cjs b/actions/setup/js/handle_agent_failure.test.cjs index b87d7831c0a..4639a54a21e 100644 --- a/actions/setup/js/handle_agent_failure.test.cjs +++ b/actions/setup/js/handle_agent_failure.test.cjs @@ -1473,6 +1473,32 @@ describe("handle_agent_failure", () => { expect(result).not.toContain("outside the allowed-files list (pkg/workflow/codex_engine.go, pkg/workflow/codex_mcp.go, pkg/workflow/compiler_yaml.go)"); }); + it("falls back to raw error line for non-matching allowed-files text", () => { + const errors = "create_pull_request:Cannot create pull request: some other error message."; + const result = buildCodePushFailureContext(errors); + expect(result).toContain("Cannot create pull request: some other error message."); + expect(result).not.toContain("
"); + }); + + it("uses singular wording for one blocked file", () => { + const errors = "create_pull_request:Cannot create pull request: patch modifies files outside the allowed-files list " + "(pkg/foo.go). Add the files to the allowed-files configuration field or remove them from the patch."; + const result = buildCodePushFailureContext(errors); + expect(result).toContain("Show 1 blocked file"); + expect(result).toContain("`pkg/foo.go`"); + }); + + it("renders bundle remediation variant", () => { + const errors = + "create_pull_request:Cannot create pull request: patch modifies files outside the allowed-files list " + + "(pkg/workflow/compiler(bundle).go, pkg/workflow/compiler_yaml.go). " + + "Add the files to the allowed-files configuration field or remove them from the bundle."; + const result = buildCodePushFailureContext(errors); + expect(result).toContain("remove them from the bundle."); + expect(result).toContain("`pkg/workflow/compiler(bundle).go`"); + expect(result).toContain("`pkg/workflow/compiler_yaml.go`"); + expect(result).toContain("Show 2 blocked files"); + }); + it("shows both sections when protected file and non-protected-file errors are mixed", () => { const errors = [ "create_pull_request:Cannot create pull request: patch modifies package manifest files (package.json). Set allow-manifest-files: true in your workflow to allow this.", From 1afd0da676d80f9c8837a390280228f0ade6f726 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 1 Jul 2026 11:33:49 +0000 Subject: [PATCH 6/6] Tighten allowed-files regex and expand tests Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- actions/setup/js/handle_agent_failure.cjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/setup/js/handle_agent_failure.cjs b/actions/setup/js/handle_agent_failure.cjs index 57cd3b284a2..becd2131f85 100644 --- a/actions/setup/js/handle_agent_failure.cjs +++ b/actions/setup/js/handle_agent_failure.cjs @@ -42,7 +42,7 @@ const ELLIPSIS_LENGTH = ELLIPSIS.length; const ENGINE_RATE_LIMIT_429_RE = /(?:\b429\b[\s\S]{0,120}(?:too many requests|rate[\s-]*limit)|\brate_limit_(?:error|exceeded)\b|capierror:\s*429|failed to get response from the ai model[\s\S]{0,120}\b429\b|exceeded your rate limit for utility models)/i; const ENGINE_MAX_RUNS_EXCEEDED_RE = /(?:\bmax_runs_exceeded\b|\bmaximum\s+llm\s+invocations\s+exceeded\b)/i; -const ALLOWED_FILES_ERROR_RE = /^(?.*outside the allowed-files list) \((?.+)\)\. (?Add the files to the allowed-files configuration field or remove them from the (?:patch|bundle)\.)$/; +const ALLOWED_FILES_ERROR_RE = /^(?.*outside the allowed-files list) \((?.+?)\)\. (?Add the files to the allowed-files configuration field or remove them from the (?:patch|bundle)\.)$/; /** * Parse action failure issue expiration from environment.