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
{{ message }}
Repository navigation
Invalid messages crash a channel's message queue, and blocks can't be sent #19
send_message/2 accepts any message and returns :ok, and the channel's Slack.MessageServer only fails when it gets to that message. When it crashes, every message queued behind it for that channel is lost, and repeated crashes can take down Slack.DynamicSupervisor along with every other channel's queue.
Two ways to hit it:
A message that isn't a string, map or keyword list, for example send_message("C1", 123), raises Protocol.UndefinedError in Enum.into/2.
A message with a list value, for example send_message("C1", %{text: "hi", blocks: [...]}), raises ArgumentError because Slack.API.post/3 sends a form body and URI.encode_query/1 doesn't accept lists. The workaround today is blocks: Jason.encode!(blocks).
This happens on main as well as with on-demand queues (#18).
Possible fixes:
Validate the message in send_message/2, so a bad one returns {:error, reason} there instead of crashing the queue.
Post chat.postMessage as JSON (Slack accepts JSON bodies for it), or JSON-encode list and map values, so blocks and attachments can be passed as data.
Rescue a failed post in the queue, log it, and move on to the next message.
Activity