From fc48a2e20b5a62f0c4dfb3e76a7ff6a7295b87d1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 24 Jan 2026 11:24:22 +0000 Subject: [PATCH 1/3] Initial plan From 540757ca160826f335d0935042238841150a3c6f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 24 Jan 2026 11:31:18 +0000 Subject: [PATCH 2/3] Initial investigation of markdown code region balancer bug Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- .github/workflows/github-remote-mcp-auth-test.lock.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/github-remote-mcp-auth-test.lock.yml b/.github/workflows/github-remote-mcp-auth-test.lock.yml index e68e97abe7..66e01c53b9 100644 --- a/.github/workflows/github-remote-mcp-auth-test.lock.yml +++ b/.github/workflows/github-remote-mcp-auth-test.lock.yml @@ -396,6 +396,11 @@ jobs: "X-MCP-Readonly": "true", "X-MCP-Toolsets": "repos,issues,discussions" }, + "tools": [ + "get_repository", + "list_issues", + "issue_read" + ], "env": { "GITHUB_PERSONAL_ACCESS_TOKEN": "\${GITHUB_MCP_SERVER_TOKEN}" } From a4288b1787e2034a96a525f3d5336d88bab7d1e6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 24 Jan 2026 11:37:32 +0000 Subject: [PATCH 3/3] Fix markdown code region balancer quality check bug The balancer was incorrectly rejecting valid fixes when a shorter fence cannot close a longer fence. For example, ``` (3 backticks) cannot close ```` (4 backticks), so the ``` should be treated as content inside the unclosed block, not as a separate unclosed fence. The bug was in the isInsideBlock helper function which only checked for paired blocks, not unclosed blocks. This caused the algorithm to add both fences to unclosedFences, which resulted in incorrect quality check rejection. Fix: Updated isInsideBlock to also check if a line is inside an unclosed block, preventing inner fences from being treated as separate openers. Added regression test for the bug found in workflow run #21314236532. Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- .../js/markdown_code_region_balancer.cjs | 13 ++++++++++- .../js/markdown_code_region_balancer.test.cjs | 23 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/actions/setup/js/markdown_code_region_balancer.cjs b/actions/setup/js/markdown_code_region_balancer.cjs index 30ca9b551e..11f7a46066 100644 --- a/actions/setup/js/markdown_code_region_balancer.cjs +++ b/actions/setup/js/markdown_code_region_balancer.cjs @@ -132,13 +132,24 @@ function balanceCodeRegions(markdown) { const unclosedFences = []; const pairedBlocks = []; // Track paired blocks with their line ranges - // Helper function to check if a line is inside any paired block + // Helper function to check if a line is inside any paired or unclosed block const isInsideBlock = lineIndex => { + // Check if inside a successfully paired block for (const block of pairedBlocks) { if (lineIndex > block.start && lineIndex < block.end) { return true; } } + + // Check if inside an unclosed block + // An unclosed block starts at an opening fence and extends to the end of the document + // if no closer was found + for (const fence of unclosedFences) { + if (lineIndex > fence.lineIndex) { + return true; + } + } + return false; }; diff --git a/actions/setup/js/markdown_code_region_balancer.test.cjs b/actions/setup/js/markdown_code_region_balancer.test.cjs index 811bf9eb2a..9a8be8df13 100644 --- a/actions/setup/js/markdown_code_region_balancer.test.cjs +++ b/actions/setup/js/markdown_code_region_balancer.test.cjs @@ -477,6 +477,29 @@ content \`\`\`\`\`\`\`\`\`\`\`\`\`\`\`\``; expect(balancer.balanceCodeRegions(input)).toBe(input); }); + + it("should close unmatched opening fence when shorter fence cannot close it", () => { + // Regression test for GitHub Issue #11630 + // When a 4-backtick fence is opened but only a 3-backtick fence follows, + // the 3-backtick fence should be treated as content inside the code block, + // not as a separate unclosed fence. + const input = `#### NPM Versions Available + +\`\`\`\` +0.0.56 +0.0.57 +0.0.58 +\`\`\``; + const expected = `#### NPM Versions Available + +\`\`\`\` +0.0.56 +0.0.57 +0.0.58 +\`\`\` +\`\`\`\``; + expect(balancer.balanceCodeRegions(input)).toBe(expected); + }); }); describe("trailing content after fence", () => {