fix: prevent bot loop on pull_request.edited events#67
Conversation
The gatekeeper's bot-author check was only effective for issue_comment events because CommentAuthor was only set from comment.user.login. For pull_request.edited (and other PR) events the field stayed empty, causing the guard `if ctx.Issue.CommentAuthor != ""` to short-circuit and skip the isBotAuthor check entirely. As a result, bot-triggered pull_request.edited events (e.g. coderabbitai updating a PR review) passed through the gatekeeper and re-ran the triage pipeline, posting duplicate triage comments and labels (#62 fix partial). Fix: fall back to sender.login in enrichIssueFromGitHubEvent when CommentAuthor is not already set. sender is present in all GitHub webhook payloads and correctly identifies who triggered the event, giving the gatekeeper full coverage across all event types. Signed-off-by: Kavirubc <hapuarachchikaviru@gmail.com>
📝 WalkthroughWalkthroughModified the comment author attribution logic in Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
Simili Triage ReportNote Quality Score: 8.8/10 (Good) Classification
Quality Improvements
Similar Threads
Generated by Simili Bot |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
cmd/simili/commands/process.go (1)
332-336: Consider renamingCommentAuthorto reflect broader usage.The field
CommentAuthoris now semantically overloaded—it holds the comment author forissue_commentevents but the event sender for other event types (e.g.,pull_request.edited). This could confuse future maintainers who expect the field to relate only to comments.A cleaner approach would be to introduce a dedicated field like
EventSenderorEventActorand have the gatekeeper check both fields, or renameCommentAuthorto something more general likeTriggeringActor.This is not a blocker for the current fix, but worth considering in a follow-up refactor.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@cmd/simili/commands/process.go` around lines 332 - 336, The CommentAuthor field is being used for both comment authors and event senders—introduce a new, more general field (e.g., EventSender or EventActor or TriggeringActor) on the same struct, populate it from the raw["sender"] login when present (in addition to keeping CommentAuthor for comment-specific data), and update any gatekeeper checks to consult the new EventSender field (or check both CommentAuthor and EventSender) so consumers clearly distinguish comment authors from generic event actors; ensure you update usages in process.go where CommentAuthor is set and where gatekeeper logic reads it to reference the new field appropriately.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@cmd/simili/commands/process.go`:
- Around line 332-336: The CommentAuthor field is being used for both comment
authors and event senders—introduce a new, more general field (e.g., EventSender
or EventActor or TriggeringActor) on the same struct, populate it from the
raw["sender"] login when present (in addition to keeping CommentAuthor for
comment-specific data), and update any gatekeeper checks to consult the new
EventSender field (or check both CommentAuthor and EventSender) so consumers
clearly distinguish comment authors from generic event actors; ensure you update
usages in process.go where CommentAuthor is set and where gatekeeper logic reads
it to reference the new field appropriately.
Summary
Closes a residual loop not covered by #62.
Root cause: The gatekeeper's bot-author check relied on
CommentAuthor, which was only populated forissue_commentevents (fromcomment.user.login). Forpull_request.editedand other PR eventsCommentAuthorstayed empty, so this guard always short-circuited:What this caused: When
coderabbitai[bot](or any bot) edits a PR (e.g. submitting a review), GitHub fires apull_request.editedevent. The gatekeeper could not detect the actor was a bot, so the triage pipeline ran again — posting a duplicate triage report and applying additional labels.Fix: In
enrichIssueFromGitHubEvent, fall back tosender.loginwhenCommentAuthoris not already set. Thesenderfield is present in all GitHub webhook payloads and correctly identifies who triggered the event — giving the gatekeeper full coverage across all event types, not just comments.How it works
issue_comment(bot comment)pull_request.editedby botpull_request.openedby humanpull_request.synchronizeby humanTest plan
go build ./...go test ./...Summary by CodeRabbit