You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the Bug:
The Slack delivery method throws an error when attempting to parse a plain text response from the Slack webhook endpoint as JSON.
When setting up a Slack notification, the limited documentation and accepted configuration led me to believe that the delivery method expected the incoming_webhook.url returned during the OAuth handshake.
After further investigation and checking the default URL in the class, I found that it actually calls the https://slack.com/api/chat.postMessage endpoint, which returns a JSON response. After setting the Authorization header and specifying the channel in the JSON body, I was able to deliver a message. However:
It would be helpful if we could optionally use the webhook URL, as this approach requires less configuration.
Alternatively, the documentation should clearly state that this delivery method is designed to work with the chat.postMessage endpoint.
Failed enqueuing Noticed::EventJob to Inline(default): JSON::ParserError (unexpected character: 'ok')
↳ (pry):4:in `<main>'
JSON::ParserError: unexpected character: 'ok'
from /Users/tomcoates/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/json-2.10.1/lib/json/common.rb:245:in `parse'
To Reproduce:
Configure notifier:
# frozen_string_literal: trueclassTestNotifier < ApplicationNotifierdeliver_by:slackdo |config|
config.url=->{slack_webhook_url}config.json=->do{text: "Hello, world"}endendprivatenotification_methodsdodefslack_webhook_url# Set your webhook URL"https://hooks.slack.com/services/your/webhook/url"endendend
Deliver notification:
TestNotifier.deliver(User.first)
Expected Behavior:
Requests should not raise an error unless config.raise_if_not_ok = true is set. The response should be correctly processed based on its content type.
Actual Behavior:
A JSON::ParserError is raised when the response is not JSON.
Screenshots (if applicable):
Environment:
Noticed gem version: 2.5.1, 2.6.0
Ruby version: 3.3.4
Rails version: 8.0.1
Operating System: macOS
Possible Fix:
Only call JSON.parse if the response has Content-Type: application/json.
Improve documentation to clarify that the delivery method is intended for chat.postMessage.
Checklist:
I have searched for similar issues and couldn't find any.
I have checked the documentation for relevant information.
I have included all the required information.
The text was updated successfully, but these errors were encountered:
Bug Report
Describe the Bug:
The Slack delivery method throws an error when attempting to parse a plain text response from the Slack webhook endpoint as JSON.
When setting up a Slack notification, the limited documentation and accepted configuration led me to believe that the delivery method expected the
incoming_webhook.url
returned during the OAuth handshake.After further investigation and checking the default URL in the class, I found that it actually calls the
https://slack.com/api/chat.postMessage
endpoint, which returns a JSON response. After setting theAuthorization
header and specifying the channel in the JSON body, I was able to deliver a message. However:chat.postMessage
endpoint.To Reproduce:
Expected Behavior:
Requests should not raise an error unless
config.raise_if_not_ok = true
is set. The response should be correctly processed based on its content type.Actual Behavior:
A
JSON::ParserError
is raised when the response is not JSON.Screenshots (if applicable):

Environment:
Possible Fix:
JSON.parse
if the response hasContent-Type: application/json
.chat.postMessage
.Checklist:
The text was updated successfully, but these errors were encountered: