mattermost / mattermost-plugin-github

GitHub plugin for Mattermost
Apache License 2.0
157 stars 150 forks source link

Pull Request Reviews are not posted. #686

Closed niklas closed 1 year ago

niklas commented 1 year ago

When Pull Request Reviews are submitted (Comment, Approve, Change Requested), no message appears in the subscribed channel

Reproduction steps:

  1. Set up Github Plugin as in instructions (company-wide webhook)
  2. Open PR (is posted in channel)
  3. Post a normal comment on PR (is posted, too)
  4. Add a PR Review (NOT posted)

Logging

When enabling DEBUG logging, the following line appears:

{"timestamp":"2023-07-11 12:23:12.556 Z","level":"debug","msg":"Unhandled review state","caller":"app/plugin_api.go:970","plugin_id":"github","state":"approved"}

Investigation:

Looking at webhook.go:827, the review state is checked against uppercase APPROVED, but it seems to be lowercase approved. Same goes fort the other PR review actions.

Extras

Here is the payload from the github webhook settings page (cleared private data):

{
  "action": "submitted",
  "review": {
    "id": 1234567,
    "node_id": "PRR_XXXXX",
    "user": {
      "login": "niklas",
     [..]
    },
    "body": "Thanks, that looks better. I'll change the wording to German.",
    "commit_id": "abcdedf123345",
    "submitted_at": "2023-07-11T11:38:40Z",
    "state": "approved",
    "html_url": "---",
    "pull_request_url": "----",
    "author_association": "CONTRIBUTOR",
    "_links": {
      "html": {
        "href": "---"
      },
      "pull_request": {
        "href": "---"
      }
    }
  },
[...]
}

As one can see, github sends review.state = "approved" (lowercase).

niklas commented 1 year ago

Thank you. <3