Python-slack-sdk: chat_update fails to update block messages to text messages

Created on 3 Oct 2019  路  2Comments  路  Source: slackapi/python-slack-sdk

Description

The chat_update method fails to update messages that use blocks when text is used for the update. This happens despite the request response having "ok": True.

What type of issue is this? (place an x in one of the [ ])

  • [x] bug
  • [ ] enhancement (feature request)
  • [ ] question
  • [ ] documentation related
  • [ ] testing related
  • [ ] discussion

Requirements (place an x in each of the [ ])

  • [x] I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • [x] I've read and agree to the Code of Conduct.
  • [x] I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

slackclient version: 2.2.0

python version: 3.7

OS version(s): macOS 10.14.6

Steps to reproduce:

  1. Use chat_postMessage to post a message with blocks instead of text
  2. Try to update it with chat_update using text instead of blocks

Expected result:

The message should update

Actual result:

Nothing happens (but ok is received in response)

2x question web-client

Most helpful comment

The ok: true response means the text attribute is successfully updated (but it's not visible for humans). It's possible to remove the blocks by giving an empty array as below:

import slack

client = slack.WebClient(token='xoxb-xxx-xxx-xxx')
post_resp = client.chat_postMessage(
    channel='C12345678',
    user='U12345678',
    text='initial',
    blocks=[
        {
            "type": "section",
            "text": {
                "type": "mrkdwn",
                "text": "This is a mrkdwn section block :ghost: *this is bold*, and ~this is crossed out~, and <https://google.com|this is a link>"
            }
        }
    ]
)
print(post_resp)

ts = post_resp['message']['ts']
update_resp = client.chat_update(
    channel='C12345678',
    user='U12345678',
    ts=ts,
    text='modified',
    blocks=[]
)
print(update_resp)

All 2 comments

The ok: true response means the text attribute is successfully updated (but it's not visible for humans). It's possible to remove the blocks by giving an empty array as below:

import slack

client = slack.WebClient(token='xoxb-xxx-xxx-xxx')
post_resp = client.chat_postMessage(
    channel='C12345678',
    user='U12345678',
    text='initial',
    blocks=[
        {
            "type": "section",
            "text": {
                "type": "mrkdwn",
                "text": "This is a mrkdwn section block :ghost: *this is bold*, and ~this is crossed out~, and <https://google.com|this is a link>"
            }
        }
    ]
)
print(post_resp)

ts = post_resp['message']['ts']
update_resp = client.chat_update(
    channel='C12345678',
    user='U12345678',
    ts=ts,
    text='modified',
    blocks=[]
)
print(update_resp)

I've answered this question then. Allow me to close this issue now. If you have something to ask/discuss further, please feel free to reopen it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

schlegelp picture schlegelp  路  3Comments

seratch picture seratch  路  3Comments

sofya-salmanova picture sofya-salmanova  路  5Comments

ErikKalkoken picture ErikKalkoken  路  3Comments

naveenjafer picture naveenjafer  路  4Comments