cpanato / mattermost-plugin-statuspage

StatusPage Notification to Mattermost
Apache License 2.0
13 stars 1 forks source link

Notifications not posted to channel #3

Closed maartenberg closed 5 years ago

maartenberg commented 5 years ago

We've enabled this plugin on a server running Mattermost Team edition v5.10, and notifications aren't posted to the channel we picked, possibly because Statuspage changed the format of their webhooks.

The webhook's payload is sent in a POST request with Content-type: application/x-www-form-urlencoded, which doesn't seem to be handled properly by the plugin. The request body seems to be interpreted as JSON directly, while the body first needs to be decoded.

Debug logs:

{"level":"info","ts":1557316687.5624783,"caller":"mlog/sugar.go:19","msg":"Received statuspage notification","plugin_id":"statuspage","service=":"NAMEOFSERVICE"}
{"level":"debug","ts":1557316687.5630443,"caller":"mlog/sugar.go:15","msg":"Failed to serve HTTP request","plugin_id":"statuspage","Error message":"invalid character 'p' looking for beginning of value"}

Received request body (intercepted using https://webhook.site):

payload=%7B%22username%22%3A%22statuspageio%22%2C%22channel%22%3A%22%23testing123%22%2C%22text%22%3A%22%22%2C%22attachments%22%3A%5B%7B%22color%22%3A%22warning%22%2C%22pretext%22%3A%22TEST+Status+page+page%22%2C%22text%22%3A%22*user%email.com*+updated+component+*TEST+Application*+from+*Degraded+Performance*+to+*Major+Outage*.%5Cn%5Cu003chttp%3A%2F%2Fmanage.statuspage.io%2Fpages%2Fabcd1234abcd%2Fcomponents%3Futm_source%3Dslack%7CManage+your+Components%5Cu003e%22%2C%22fallback%22%3A%22user%40email.com+updated+component+TEST+Application+from+Degraded+Performance+to+Major+Outage.+%22%7D%5D%7D

Decoded payload:

{
  "username": "statuspageio",
  "channel": "#testing123",
  "text": "",
  "attachments": [
    {
      "color": "warning",
      "pretext": "TEST Status page page",
      "text": "*user@email.com* updated component *TEST Application* from *Degraded Performance* to *Major Outage*.\n<http://manage.statuspage.io/pages/abcd1234abcd/components?utm_source=slack|Manage your Components>",
      "fallback": "user@email.com updated component TEST Application from Degraded Performance to Major Outage. "
    }
  ]
}
cpanato commented 5 years ago

Thanks for the report @maartenberg The plugin is running on https://community.mattermost.com without any issues, we are using github, gitlab, circleci, travis, zoom and others statuspages notification configuration without any issues.

notice in your side you did not set the service name in the webhook url might be this issue:

https://SITEURL/plugins/statuspage/webhook?service=SERVICENAME&token=TOKEN

where SERVICENAME is the service you are subscribing, like github and the TOKEN is the token you generated in the settings page for the plugin.

One question what is this payload that you posted? this is not the statuspage payload. statuspage payload is something like:

{
   "meta":{
      "unsubscribe":"http://statustest.flyingkleinbrothers.com:5000/?unsubscribe=j0vqr9kl3513",
      "documentation":"http://doers.statuspage.io/customer-notifications/webhooks/"
   },
   "page":{
      "id": "j2mfxwj97wnj",
      "status_indicator": "major",
      "status_description": "Partial System Outage"
   },
   "component_update":{
      "created_at":"2013-05-29T21:32:28Z",
      "new_status":"operational",
      "old_status":"major_outage",
      "id":"k7730b5v92bv",
      "component_id":"rb5wq1dczvbm"
   },
   "component":{
      "created_at":"2013-05-29T21:32:28Z",
      "id":"rb5wq1dczvbm",
      "name":"Some Component",
      "status":"operational"
   }
}

https://help.statuspage.io/knowledge_base/topics/webhook-notifications

maartenberg commented 5 years ago

Hi @cpanato,

I now realise that I misunderstood the plugin's purpose. I used the plugin's webhook as the target for the Slack integration, where we should have subscribed it to an actual webhook as a subscriber. I've tested it with the correct setup and everything works as expected.