Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions actions/setup/js/log_parser_shared.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -1524,9 +1524,9 @@ function formatSafeOutputsPreview(safeOutputsContent, options = {}) {
preview.push("<details>");
preview.push("<summary>Preview</summary>");
preview.push("");
preview.push("```");
preview.push("``````");
preview.push(bodyPreview);
preview.push("```");
preview.push("``````");
preview.push("</details>");
preview.push("");
}
Expand Down
4 changes: 2 additions & 2 deletions actions/setup/js/safe_output_summary.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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`;
Expand All @@ -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`;
}
}

Expand Down
47 changes: 47 additions & 0 deletions actions/setup/js/safe_output_summary.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading