python-slack-sdk icon indicating copy to clipboard operation
python-slack-sdk copied to clipboard

Non-hex colors (danger/good/warn) are not displayed by `BlockAttachment`s

Open ADraginda opened this issue 3 years ago • 4 comments

Reproducible in:

The Slack SDK version

slack-sdk 3.19.5

Python runtime version

python 3.7.15

OS info

ProductName: macOS ProductVersion: 13.2 BuildVersion: 22D49 Darwin Kernel Version 22.3.0: Thu Jan 5 20:48:54 PST 2023; root:xnu-8792.81.2~2/RELEASE_ARM64_T6000


Steps to reproduce:

from slack_sdk import WebClient

CHANNEL = "INSERT A CHANNEL HERE"
TOKEN = "INSERT A SLACK TOKEN HERE"

text = "Lorem ipsum dolor sit amet, consectetur adipiscing eli"
client = WebClient(token=TOKEN)
client.chat_postMessage(
    channel=CHANNEL,
    text=text,
    attachments=[
        BlockAttachment(
            blocks=[SectionBlock(text=text)],
            color='danger'
        )
    ]
)

Expected result:

I expect the attachment color to be RED (color='danger')

Actual result:

The color is grey

Screenshot 2023-02-15 at 4 47 45 PM

Also

I noticed that

BlockAttachment(blocks=[SectionBlock(text=text)], color='danger').color_valid()

ReturnsNone instead of True (and returns None regardless of whatever color I use, including hex codes)

Note that I also tried color "good" (same result - banner is grey)

But if I use a hex code for the color argument, the color will be displayed properly.

Screenshot 2023-02-15 at 4 55 20 PM

ADraginda avatar Feb 16 '23 00:02 ADraginda

Hi @ADraginda, thanks for writing in! Unfortunately, the attachments do not support non-hex color names unlike blocks (Block Kit). So, please go ahead with a color code. I hope this helps.

seratch avatar Feb 16 '23 03:02 seratch

Ah! That would explain it, thanks. Consider updating the docs as the entry for BlockAttachment suggests that you can use words for colors.

ADraginda avatar Feb 16 '23 04:02 ADraginda

Thanks a lot for pointing the issue out! I will improve it later.

seratch avatar Feb 16 '23 04:02 seratch

Updated the docs. Thanks again for flagging this!

seratch avatar Feb 16 '23 06:02 seratch