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
7 changes: 4 additions & 3 deletions actions/setup/js/close_issue.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
const { resolveTargetRepoConfig, resolveAndValidateRepo, validateRepo } = require("./repo_helpers.cjs");
const { createAuthenticatedGitHubClient } = require("./handler_auth.cjs");
const { ERR_NOT_FOUND } = require("./error_codes.cjs");
const { createCloseEntityHandler, ISSUE_CONFIG } = require("./close_entity_helpers.cjs");
const { createCloseEntityHandler, buildCommentBody, ISSUE_CONFIG } = require("./close_entity_helpers.cjs");
const { loadTemporaryIdMapFromResolved, resolveRepoIssueTarget } = require("./temporary_id.cjs");
const { getErrorMessage } = require("./error_helpers.cjs");
const { normalizeIssueIntentMetadata } = require("./issue_intents.cjs");
Expand Down Expand Up @@ -297,8 +297,9 @@ async function main(config = {}) {
},

buildCommentBody(sanitizedBody) {
// Issues post the sanitized body directly without a workflow footer
return sanitizedBody;
const triggeringIssueNumber = context.payload?.issue?.number;
const triggeringPRNumber = context.payload?.pull_request?.number;
return buildCommentBody(sanitizedBody, triggeringIssueNumber, triggeringPRNumber);
},

addComment: addIssueComment,
Expand Down
8 changes: 6 additions & 2 deletions actions/setup/js/close_issue.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,8 @@ describe("close_issue", () => {
expect(result.success).toBe(true);
expect(commentCalls.length).toBe(1);
expect(commentCalls[0].body).toContain("This issue is being closed automatically");
expect(commentCalls[0].body).toContain("for #123");
expect(commentCalls[0].body).toContain("gh-aw-agentic-workflow:");
});

it("should use body field from message over config comment", async () => {
Expand Down Expand Up @@ -413,7 +415,9 @@ describe("close_issue", () => {
expect(result.success).toBe(true);
expect(commentCalls.length).toBe(1);
// Should use the body from message, not the config comment
expect(commentCalls[0].body).toBe("Custom body from message");
expect(commentCalls[0].body).toContain("Custom body from message");
expect(commentCalls[0].body).toContain("for #123");
expect(commentCalls[0].body).toContain("gh-aw-agentic-workflow:");
expect(commentCalls[0].body).not.toContain("Default comment from config");
});

Expand Down Expand Up @@ -506,7 +510,7 @@ describe("close_issue", () => {

expect(result.success).toBe(true);
expect(result.alreadyClosed).toBe(true);
expect(commentBody).toBe("Closing comment with details");
expect(commentBody).toContain("Closing comment with details");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same concern as line 416: .toContain(body) alone doesn't confirm the footer was appended. The test would still pass if buildCommentBody is reverted to returning sanitizedBody directly. Add an assertion on a footer-specific token, e.g.:

expect(commentBody).toContain("<!-- gh-aw"); // footer sentinel

@copilot please address this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/diagnosing-bugs] Same weakened assertion as line 416 — .toContain passes even if the footer is absent, so this test does not guard the regression fixed by this PR. Add a footer-specific assertion to confirm the footer was actually appended.

💡 Suggested fix
expect(commentBody).toContain("Closing comment with details");
// confirm footer was appended
expect(commentBody.length).toBeGreaterThan("Closing comment with details".length);

Or match a known footer marker string from buildCommentBody.

@copilot please address this.

expect(issueUpdateCalled).toBe(false); // Should not call update for already closed issue
});

Expand Down
Loading