Repository navigation
test(gitea): cover signed comment webhook dispatch - #3575
IsmaelMartinez merged 1 commit into
Conversation
Exercise Gitea's native comment headers through signature validation and background dispatch. PR timeline comments use the normalized issue_comment event, while pull_request_comment is the specific event-type header. Cover slash-command delivery, ignored edits and non-command comments, issue-only payloads, distinct review events, and rejected signatures. Preserve the existing production event routing rather than adding an unsupported alias based on the internal event name.
PR Summary by QodoCover signed Gitea comment webhook dispatch
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
Code Review by Qodo
1. Webhook note uses narrative phrasing
|
IsmaelMartinez
left a comment
There was a problem hiding this comment.
Thanks for tracing Gitea's event normalisation back to its source and encoding it as a signed end-to-end test rather than a routing change. Approving.
The signature check runs for real: flipping the HMAC comparison turns 13 of 14 cases red, and the missing-header case rightly stays green since it is rejected earlier. None of these entry points had unit coverage before. Qodo's line 73 phrasing note is a platform rule, not this repo's convention, so the comment can stand. CI is green.
Summary
Add regression coverage for signed Gitea pull-request comment webhooks through the real signature-validation, background-task, event-routing, and command-dispatch paths.
This does not change production routing. It documents and protects the webhook contract that the existing routing already implements.
Context
While reviewing Gitea webhook handling, PR timeline comments initially appeared to be missing from the production router:
gitea_app.pyhandlesX-Gitea-Event: issue_comment, while Gitea also defines an internal event namedpull_request_comment.Following that mapping through Gitea's webhook implementation shows why the existing routing is correct.
Gitea distinguishes the specific event type from the normalized event sent to webhook consumers:
HookEventPullRequestCommentis delivered asX-Gitea-Event: issue_comment, withX-Gitea-Event-Type: pull_request_comment.HookEventPullRequestReviewCommentis delivered asX-Gitea-Event: pull_request_comment, withX-Gitea-Event-Type: pull_request_review_comment.As a result, adding
pull_request_commentas an alias for normal PR timeline commands would not fix a missing route. It would instead risk conflating submitted review comments with timeline comments.The distinction is subtle because the same event names appear at different layers of Gitea's webhook model. These tests make that contract explicit so a future routing change does not accidentally collapse the two event types.
What this covers
issue_commentdispatch/review,/ask, and/improveexactly once with the original command and PR URL.pull_request_commentare not treated as timeline commands.The fixtures follow Gitea's native
IssueCommentPayload, includingissue,pull_request,comment, andis_pull.Why tests rather than a routing change
The existing production routing already matches Gitea's normalized webhook contract.
The risk is not an uncovered event, but a plausible future change based on the internal event name alone. Exercising the signed HTTP delivery path through background dispatch ensures the behavior is protected at the same boundary where Gitea actually delivers it.
Production code, dependencies, configuration, and workflows are unchanged.