JIRA webhook fails with error "unexpected end of JSON input"

Mattermost version: 5.20.1
Jira Plugin version: 2.3.2

We use the old method of posting Jira webhooks to the Mattermost: by webhook created on the Jira side. Jira sends calls webhook and sends JSON payload successfully but on the Mattermost side we always receive the next error: ‘unexpected end of JSON input’.

Full error message from the Mattermost log:
{“level”:“error”,“ts”:1584741523.2237434,“caller”:“mlog/sugar.go:23”,“msg”:“ERROR: “,“plugin_id”:“jira”,“Status”:“400”,“Error”:“unexpected end of JSON input”,“Host”:“matter:8065”,“RequestURI”:”/plugins/jira/webhook?secret=FlHvJth-3x_HsMI5iIC0yvJ1r2BhNoyb&team=blackwood&channel=test&user_id=olegok&user_key=olegok”,“Method”:“POST”,“query”:“channel=test&secret=FlHvJth-3x_HsMI5iIC0yvJ1r2BhNoyb&team=blackwood&user_id=olegok&user_key=olegok”}

The issue can be reproduced with Curl:
curl -v --insecure “http://matter:8065/plugins/jira/webhook?secret=FlHvJth-3x_HsMI5iIC0yvJ1r2BhNoyb&team=blackwood&channel
=test&user_id=olegok&user_key=olegok” --data ‘{“WebhookEvent”:“IssueUpdated”}’

@paulrothrock Would the support team be familiar with this issue?

Hey,
i couldn’t reproduce with your versions. Is there any reason why you use the Jira webhook instead of the app connection? Can you try to setup using /jira install server URL and afterwards follow the commands Mattermost prints out? This should work without problems. Another possibility might be to regenerate the secrets and create the webhook again.

Hi,

The reason we use Jira-side webhooks is the need to filter issues by parent task: we need to post to the mattermost any changes in the all sub-tasks of the given task. Its not possible to setup such behaviour via current UI that jira plugin provides.
We already did “/jira install” for our Jira server. Probably it doesn’t make sense to regenerate the key since the basic webhook that posts ALL Jira changes to the mattermost works fine ("/jira subscribe" posts changes successfully to the channels)

@K1tty I’ve asked our Jira Plugin team if there’s a way to do this with the current plugin and as soon as I hear back from them I’ll let you know.

Would it be possible to capture the entire payload the Jira server is sending? The error message seems to indicate it’s not formatted correctly. Here’s an example payload that you can use to test your webhook.

Its output from the Jira log. Mattermost for some reason does not show webhook payload even with “File\Console Log Level = DEBUG” and “Enable WebHook debugging = TRUE”.

Posting via Curl with your example payload works fine (i see the message in the mattermost). Posting with the payload from the log file I’ve attached above still does not produce mattermost message (but receives HTTP code 200 OK). Also I found that “unexepected end of JSON input” received when there is no ContentType sepecified in Curl. So probably Jira sens webhook with incorrect ContentType.

From my further experiments I can say that its problem with Jira Sub-Task’s updates:

  1. When mattermost receives notifications about normal tasks (that have no parent) I see the messages
  2. When sub-task issue created/updated - I don’t see the message (but it comes to the mattermost according to the its logs)
  3. But when sub-task issue deleted or Assignee changed - I see the notification in the chat (its really weird since its inconsistent with p.2)

Do you have reproduce with my JSON file?

@K1tty A screenshot of the Jira plugin settings and the filters, as well as your Mattermost logs would also be helpful. Then I can replicate the issue in a local instance and file a bug report.

Today we’ve updated Jira to the version 8.8 and now sub-task tickets status/resolution updates work (i see update messages in mattermost). But still don’t work: comments updates, worklog updates, other fields updates (priority, components).
You can find requested screenshots and mattermost log here: https://drive.google.com/file/d/1IsmYTsCSDi0CosvnvoXdBZHxMclL4LIS/view