Slack Bug 1 - long mrkdwn blocks with ```preformatted``` text


The Issue

Here is a script that demonstrates the bug
#!/bin/sh

# Input to curl is second line and is very long.  Changing the length of the string can change the
# demonstration of the bug.
#
# The output in slack is supposed to be a number of "---...--" lines followed by four blocks
# that say "Here is more info:" followed by ```tables``` of multiple lines.  Sometimes the
# tables are rendered as ```preformatted text``` and sometimes the '```' is rendered as if
# it was not slack code.  It all depends on the length of the message, sometimes shorter works,
# sometimes longer works.  In the following example, the first two blocks work, but the beginning
# of the third block renders as '```' causing it to get messy after that.  I've also seen examples
# where the fourth block is not rendered as preformatted text.

# You need to define your $APPURLGOESHERE to match something that will take and post mrkdown
/usr/bin/curl -k -X POST -H 'Content-type: application/json' -s -S --data @- https://hooks.slack.com/services/$APPURLGOESHERE <<HEREDOC
{"username":"NVRegress Status","channel":"@dmadison","type": "mrkdwn", "text": "----------------------------------------------------------------------------------------\n----------------------------------------------------------------------------------------\n----------------------------------------------------------------------------------------\n----------------------------------------------------------------------------------------\n----------------------------------------------------------------------------------------\n----------------------------------------------------------------------------------------\n----------------------------------------------------------------------------------------\n----------------------------------------------------------------------------------------\n----------------------------------------------------------------------------------------\n----------------------------------------------------------------------------------------\n----------------------------------------------------------------------------------------\n----------------------------------------------------------------------------------------\n----------------------------------------------------------------------------------------\n----------------------------------------------------------------------------------------\n----------------------------------------------------------------------------------------\n----------------------------------------------------------------------------------------\n----------------------------------------------------------------------------------------\n----------------------------------------------------------------------------------------\n\nHere is more info:!\n\`\`\`\n       TIME          CL    PASS    FAIL    RUN    PEND    NOTRUN       OPENBUGIDS!\n06/09 05:44    foobarfo     187       0     13       0         0!\n06/09 05:37    foobarfo     194       2      4       0         0 testingtestingtestingtestingtest,testingtestingtestingtestingtest,!\n06/08 05:45    foobarfo     174       0     26       0         0!\n06/08 05:45    foobarfo     180       0     20       0         0                                                                   !\n06/08 05:42    foobarfo     191       0      9       0         0                                                                   !\n\`\`\`\nHere is more info...:\n\`\`\`\n       TIME          CL    PASS    FAIL    RUN    PEND    NOTRUN       OPENBUGIDS!\n06/10 05:38    foobarfo       0     100      0       0         0                                                                   !\n06/10 05:32    foobarfo       0     100      0       0         0                                                                   !\n06/09 05:38    foobarfo       0     100      0       0         0                                                                   !\n06/09 05:38    foobarfo       0     100      0       0         0                                                                   !\n06/08 05:46    foobarfo       0     100      0       0         0                                                                   !\n06/08 05:43    foobarfo       0     100      0       0         0                                                                   !\n\`\`\`\nHere is more info...:\n\`\`\`\n       TIME          CL    PASS    FAIL    RUN    PEND    NOTRUN       OPENBUGIDS!\n06/10 05:39    foobarfo      43       7      0       0         0 testingtestingtestingtestingtest,testingtestingtestingtestingtest,!\n06/10 05:33    foobarfo      43       7      0       0         0 testingtestingtestingtestingtest,testingtestingtestingtestingtest,!\n06/09 05:32    foobarfo      44       6      0       0         0 testingtestingtestingtestingtest,testingtestingtestingtestingtest,!\n06/09 05:32    foobarfo      44       6      0       0         0 testingtestingtestingtestingtest,testingtestingtestingtestingtest,!\n06/08 05:41    foobarfo      46       4      0       0         0 testingtestingtestingtestingtest,testingtestingtestingtestingtest,!\n06/08 05:38    foobarfo      46       4      0       0         0 testingtestingtestingtestingtest,testingtestingtestingtestingtest,!\n\`\`\`\nHere is more info...:\n\`\`\`\n       TIME          CL    PASS    FAIL    RUN    PEND    NOTRUN       OPENBUGIDS!\n06/10 05:31    foobarfo      17      18     15       0         0  http://getdave.com/foo,<http://getdave.com/foo|foobars>!\n06/10 05:29    foobarfo      12      15     23       0         0  http://getdave.com/foo,<http://getdave.com/foo|foobars>!\n06/09 05:34    foobarfo      24      19      7       0         0  http://getdave.com/foo,<http://getdave.com/foo|foobars>!\n06/09 05:31    foobarfo      25      19      6       0         0  http://getdave.com/foo,<http://getdave.com/foo|foobars>!\n06/08 05:35    foobarfo      22      24      4       0         0  http://getdave.com/foo,<http://getdave.com/foo|foobars>!\n06/08 05:32    foobarfo      23      23      4       0         0  http://getdave.com/foo,<http://getdave.com/foo|foobars>!\n\`\`\`\ndone here\n" }
HEREDOC

The Cause

To their credit, Slack contacted me right away and not only root-caused the issue, they sent an explanation to me. Impressive.

The problem was that the messages were being broken into 4000 character chunks, but that split could happen across formatting such as ``` (though I imagine it could break many, many things, such as being in the midst of an icon, emoji, etc..

Screenshot of the example output:

(click for full size)