Skip to content

[BUG] Bitbucket webhook queues a review for every pullrequest:* event, including the agent's own comments #93

Closed

Description

@OkiriGabriel

Problem

In api/server.py#L521, the Bitbucket handler queues a code_review incident for every pullrequest:* event:

if event.startswith("pullrequest:") or payload.get("pullrequest"):

That includes pullrequest:comment_created, comment_updated, approved, unapproved, fulfilled (merged) and rejected (declined).

When CODE_REVIEW_AUTO_POST=true, the agent posts its review as PR comments (_bitbucket_post, summary plus one comment per finding). Each of those comments triggers pullrequest:comment_created, which queues another review, which posts more comments. If the repository's webhook subscribes to comment events, this is an infinite loop that also costs LLM tokens on every pass. Merged and declined PRs also get reviewed.

Expected

Only pullrequest:created and pullrequest:updated (with new commits) queue a review, and other events return ignored.

Suggested fix

  • Allowlist {"pullrequest:created", "pullrequest:updated"}.
  • Skip when pr.state != "OPEN".
  • Dedupe on (repo, change_id, source.commit.hash) so the same commit isn't reviewed twice.
  • Test that a comment_created payload is ignored.

Activity

  1. added
    bug
    integration
    on Oct 19, 2026
  2. added a commit that references this issue on Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugintegration

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions