From 17489a7059422efa1082d1c9c7da9489e044da6f Mon Sep 17 00:00:00 2001 From: Rodrigo Campos Date: Mon, 21 Nov 2016 11:53:19 -0300 Subject: [PATCH] Fix reporting exceptions with libyajl2 Some chef versions, like 11.14.2, may end up installing libyajl2, instead of yajl-ruby, and it seems they treat exceptions differently. The end result is that the webhook fails with "invalid_payload" and the json seems to be invalid. By just doing a "to_s", it always work (it works fine on a string too). --- files/default/slack_handler_webhook.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/default/slack_handler_webhook.rb b/files/default/slack_handler_webhook.rb index e0f02fb..468ef21 100644 --- a/files/default/slack_handler_webhook.rb +++ b/files/default/slack_handler_webhook.rb @@ -106,7 +106,7 @@ def request_body(message, text_attachment) body[:icon_emoji] = @icon_emoji end body[:channel] = @channel if @channel - body[:attachments] = [{ text: text_attachment }] unless text_attachment.nil? + body[:attachments] = [{ text: text_attachment.to_s }] unless text_attachment.nil? body.to_json end end