diff --git a/actions/setup/js/log_parser_shared.cjs b/actions/setup/js/log_parser_shared.cjs index b88fc1e568..e94300d7d6 100644 --- a/actions/setup/js/log_parser_shared.cjs +++ b/actions/setup/js/log_parser_shared.cjs @@ -1524,9 +1524,9 @@ function formatSafeOutputsPreview(safeOutputsContent, options = {}) { preview.push("
"); preview.push("Preview"); preview.push(""); - preview.push("```"); + preview.push("``````"); preview.push(bodyPreview); - preview.push("```"); + preview.push("``````"); preview.push("
"); preview.push(""); } diff --git a/actions/setup/js/safe_output_summary.cjs b/actions/setup/js/safe_output_summary.cjs index 7e3055379b..5b98cf9c1b 100644 --- a/actions/setup/js/safe_output_summary.cjs +++ b/actions/setup/js/safe_output_summary.cjs @@ -64,7 +64,7 @@ function generateSafeOutputSummary(options) { // Truncate body if too long const maxBodyLength = 500; const bodyPreview = message.body.length > maxBodyLength ? message.body.substring(0, maxBodyLength) + "..." : message.body; - summary += `**Body Preview:**\n\`\`\`\n${bodyPreview}\n\`\`\`\n\n`; + summary += `**Body Preview:**\n\`\`\`\`\`\`\n${bodyPreview}\n\`\`\`\`\`\`\n\n`; } if (message.labels && Array.isArray(message.labels)) { summary += `**Labels:** ${message.labels.join(", ")}\n\n`; @@ -76,7 +76,7 @@ function generateSafeOutputSummary(options) { // Add original message details for debugging if (message) { - summary += `**Message Details:**\n\`\`\`json\n${JSON.stringify(message, null, 2).substring(0, 1000)}\n\`\`\`\n\n`; + summary += `**Message Details:**\n\`\`\`\`\`\`json\n${JSON.stringify(message, null, 2).substring(0, 1000)}\n\`\`\`\`\`\`\n\n`; } } diff --git a/actions/setup/js/safe_output_summary.test.cjs b/actions/setup/js/safe_output_summary.test.cjs index 96a4473413..02370e41dd 100644 --- a/actions/setup/js/safe_output_summary.test.cjs +++ b/actions/setup/js/safe_output_summary.test.cjs @@ -104,6 +104,53 @@ describe("safe_output_summary", () => { expect(summary.length).toBeLessThan(longBody.length + 1000); }); + it("should use 6-backtick fences for body content containing backticks", () => { + const bodyWithBackticks = "Here is some code:\n```javascript\nconsole.log('hello');\n```\nEnd of body."; + + const options = { + type: "create_issue", + messageIndex: 1, + success: true, + result: { + repo: "owner/repo", + number: 123, + }, + message: { + title: "Issue with code", + body: bodyWithBackticks, + }, + }; + + const summary = generateSafeOutputSummary(options); + + // Should use 6-backtick fences to avoid breaking when body contains triple backticks + expect(summary).toContain("``````\n"); + expect(summary).toContain("Body Preview"); + expect(summary).toContain("```javascript"); + }); + + it("should use 6-backtick fences for error message details containing backticks", () => { + const messageWithBackticks = { + title: "Test Issue", + body: "Code: ```\nconsole.log('test');\n```", + }; + + const options = { + type: "create_issue", + messageIndex: 1, + success: false, + result: null, + message: messageWithBackticks, + error: "Failed to create issue", + }; + + const summary = generateSafeOutputSummary(options); + + // Should use 6-backtick fences for message details JSON to avoid rendering issues + expect(summary).toContain("``````json\n"); + expect(summary).toContain("Message Details"); + }); + it("should handle project-specific results", () => { const options = { type: "create_project",