Skip to content

fix: use configurable bot ID for sticky comment search#1123

Open
sxlehman-godaddy wants to merge 1 commit intoanthropics:mainfrom
sxlehman-godaddy:fix/sticky-comment-bot-id-mismatch
Open

fix: use configurable bot ID for sticky comment search#1123
sxlehman-godaddy wants to merge 1 commit intoanthropics:mainfrom
sxlehman-godaddy:fix/sticky-comment-bot-id-mismatch

Conversation

@sxlehman-godaddy
Copy link
Copy Markdown

Problem

use_sticky_comment: "true" never finds existing comments to update, causing duplicate comments on every workflow run. Two independent bugs cause this:

1. Hardcoded bot ID mismatch

create-initial.ts defines a local CLAUDE_APP_BOT_ID = 209825114 (claude[bot]) that shadows the shared constant in constants.ts (41898282, github-actions[bot]). The comment search uses this value to match comment.user?.id, but the action's default bot_id is "41898282". Under the default configuration, the search never matches.

Fix: Use context.inputs.botId (configurable via the bot_id input) instead of the hardcoded constant.

2. Event type guard too restrictive

The sticky comment guard requires isPullRequestEvent(context), which only returns true for eventName === "pull_request". Comment-triggered workflows (issue_comment events on PRs) are excluded even though context.isPR is true.

Fix: Widen the guard to also match issue_comment events on PRs via isIssueCommentEvent(context) && context.isPR. Review-thread reply behavior (pull_request_review_comment events) is unchanged — they continue to use createReplyForReviewComment as before.

Changes

  • src/github/operations/comments/create-initial.ts: Removed hardcoded bot ID, use context.inputs.botId; widened sticky comment guard to include PR issue comments
  • test/create-initial-comment.test.ts: New test file with 5 regression tests covering sticky comment routing across event types

Verification

  • bun run typecheck — passes
  • bun run format:check — passes
  • bun test — 657/657 tests pass (5 new)

Impact

Affects every user running with the default github_token who enables use_sticky_comment or track_progress. Previously, duplicate comments were created on every workflow run.

Related: #759 (same root cause — bot ID mismatch — different symptom: unsigned commits)

The sticky comment search in create-initial.ts had two bugs that
caused it to never find existing comments to update, resulting in
duplicate comments on every workflow run:

1. Hardcoded bot ID mismatch: A local constant CLAUDE_APP_BOT_ID
   (209825114, claude[bot]) shadowed the shared constant in
   constants.ts (41898282, github-actions[bot]). The search used
   209825114 but the action's default bot_id is 41898282, so the
   ID match never succeeded.

2. Event type guard too restrictive: The guard required
   isPullRequestEvent(context), which only matched
   eventName === "pull_request". Comment-triggered workflows
   (issue_comment events on PRs) were excluded even though
   context.isPR was true.

Fix: Use context.inputs.botId (configurable via the bot_id input)
instead of the hardcoded constant, and widen the guard to also
include issue_comment events on PRs. Review-thread reply behavior
(pull_request_review_comment events) is unchanged.

Adds regression tests for sticky comment routing across event types.

Related: anthropics#759
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant