I'm attempting to receive AWS SNS notifications.
After configuring the AWS SNS console, the first thing it sends is a subscription confirmation message
http://docs.aws.amazon.com/sns/latest/dg/SendMessageToHttp.html
I see the headers of this request just fine, but the body/payload is not being delivered to my hook AFAICT. The AWS SNS request contains/is JSON, but Content-Type”:“text/plain; charset=UTF-8", there have been numerous complaints about this, but AWS isn't going to fix that.
One test I ran was to change the method to http, and then I used tcpdump to capture the incoming packets. In the resulting pcap file, I can see the payload info I am expecting, so that leads me to believe that perhaps the problem is with webhook itself.... I can provide this pcap file if needed (it is small)
In terms of my overall setup, on the same server, I have another hook that successfully receives POSTs from Jira Cloud, so that indicates to me that generally my server/webhook is working.
Of course, there is always the chance I am doing something dumb/wrong, but I've been trying lots of different things over the past day, and I currently don't think I've misconfigured this....
Any advice or suggestions would be appreciated.
No need to investigate further, there's nothing wrong with you. :-)
It's AWS SNS's fault for not sending the proper Content-Type header. Webhook will parse payload as json, if and only if the Content-Type header contains json.
Seeing that AWS will not change their behavior I would accept a PR for a new flag in the hook incoming-payload-content-type, which, if present, should override the contents of the incoming Content-Type header.
That way we can work around this issue.
As a temporary workaround (albeit without trigger rules), you could pass entire payload to the underlying script and do the heavy lifting with jq.
The problem is that I am not receiving the payload AT ALL to my script. There is something about this payload from AWS SNS that is causing problems with webhook, OR, I am doing something wrong.
Given that I successfully wrote a trivially simple hook script that receives the entire payload from Jira, which works fine, I am thinking that the problem is not me, there is something about these payloads that is causing a problem for webhook....
OK, I looked into this further today.
I see in webhooks.go where the body is parsed according to the Content-Type header, but I do not see how a hook can specify that the unparsed body should be passed to the underlying script.
AFAICT, entire-payload only provides a parsed payload to the underlying script.
I have established that if I override the Content-Type header and force a JSON decode of the body received from AWS SNS as JSON, everything works normally. Your proposal to configure this override behavior via a incoming-payload-content-type hook flag seems viable, and I am attempting to do that, as a first-time golang task...
Fixed in #206
Would be good to see this updated in the documentation as I spent ages wondering why AWS SNS alerts weren't working and happened to stumble upon this new hook flag.
Works a treat! Cheers!