Skip to content

fix(gitea): route PR conversation comments to handlePrComment#251

Open
SingularityKChen wants to merge 1 commit into
tmseidel:developfrom
SingularityKChen:fix/gitea-pr-comment-routing
Open

fix(gitea): route PR conversation comments to handlePrComment#251
SingularityKChen wants to merge 1 commit into
tmseidel:developfrom
SingularityKChen:fix/gitea-pr-comment-routing

Conversation

@SingularityKChen

Copy link
Copy Markdown

What

Route Gitea PR-conversation comments to handlePrComment even when the webhook payload carries the PR marker only in the nested issue.pull_request field.

Fixes #250.

Why

Gitea delivers a comment posted in a pull request's conversation as an issue_comment webhook whose PR-ness is signalled by issue.pull_request, not a top-level pull_request. GiteaWebhookHandler routed on the top-level field alone, so @-mentions on a PR fell through to handleIssueComment — which is gated behind the bot's agent feature — and were dropped with "Agent feature disabled, ignoring issue comment" when the agent was off.

How

  • Treat either signal (top-level pull_request or nested issue.pull_request) as a PR comment.
  • Promote the nested marker to a minimal top-level PullRequest (number/title/body/author copied from the issue — for PRs in Gitea these mirror the PR) before delegating, because handlePrComment dereferences payload.getPullRequest().getNumber().

Tests

  • Added GiteaWebhookHandlerTest#prConversationComment_withoutTopLevelPullRequest_routesToHandlePrComment: an issue_comment payload with issue.pull_request set and no top-level pull_request now routes to handlePrComment and carries a promoted top-level PR (asserts number == issue number). Written test-first (red → green).
  • mvn -Dtest=GiteaWebhookHandlerTest test → green (20 tests, 0 failures).

Targets develop per CONTRIBUTING.md.

🤖 Generated with Claude Code

Gitea delivers a comment posted in a pull request's conversation as an
issue_comment webhook whose PR-ness is signalled only by the nested
issue.pull_request field, not a top-level pull_request object.
GiteaWebhookHandler routed on the top-level field alone, so @-mentions
on a PR fell through to handleIssueComment -- which is gated behind the
bot's agent feature -- and were dropped with "Agent feature disabled,
ignoring issue comment" whenever the agent was disabled.

Treat either signal (top-level pull_request or nested
issue.pull_request) as a PR comment so mentions reach handlePrComment
(code review / slash commands) regardless of the agent setting. Promote
the nested marker to a minimal top-level PullRequest first, because
handlePrComment dereferences payload.getPullRequest().getNumber().

Add a regression test for the issue_comment-with-nested-PR payload.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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