Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebClient chat_postMessage doesn't support input blocks - errors with {'ok': False, 'error': 'invalid_blocks'} #1257

Closed
1 task done
kbroughton opened this issue Aug 27, 2022 · 3 comments
Labels
auto-triage-stale question M-T: User needs support to use the project

Comments

@kbroughton
Copy link

WebClient chat_postMessage doesn't support input blocks.
This may be similar to #853 where an excessive input validation needed to be removed. #519 also looks mildly similar.

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

  • slack_sdk.web.WebClient (sync/async) (Web API client)

It appears that not all valid elements in block kit tool can be posted as a message, despite the fact that message preview works fine in the Block Tool.

In my case, the code failed when I included an input block and passed when i removed it. The input block was generated by the Block Kit tool and it looked fine when selecting "Message Preview".

		{
			"type": "input",
			"element": {
				"type": "plain_text_input",
				"action_id": "plain_text_input-action"
			},
			"label": {
				"type": "plain_text",
				"text": "Feedback",
				"emoji": true
			}
		}

The error was
{'ok': False, 'error': 'invalid_blocks'}

If messages are not meant to support input fields, then the Message Preview should fail in Block Kit Tool. It doesn't.

Also, although the documentation for python says you need to urlEncode the JSON-based array, there is no example of using "blocks" in the python sample code, and the description at https://api.slack.com/methods/chat.postMessage#arg_blocks is incorrect. Documentation fix needed

You can see on line 29 in the SDK test code below that blocks= takes a regular list of dicts, not a string.
https://github.com/slackapi/python-slack-sdk/blob/c9dc6aa0907a72c16cf36aa15e7e80031a9fdce2/integration_tests/samples/basic_usage/sending_a_message.py

I've created a gist to reproduce the issue https://gist.github.com/kbroughton/e46edc3f6454c8dc33a09431b5685a6c

@seratch seratch added question M-T: User needs support to use the project and removed untriaged labels Aug 29, 2022
@seratch
Copy link
Member

seratch commented Aug 29, 2022

Hi @kbroughton, thanks for writing in!

I've checked your gist and found that the reason why your code is getting "invalid_blocks" error code from the server side is that you have an input block element under an "actions" block, which is not available in Block Kit. Your app needs to have any blocks at the top level, not under a block.

You can see the detailed error in Block Kit Builder here.

Here is a working example in Block Kit Builder.

I hope this helps.

@github-actions
Copy link

github-actions bot commented Oct 3, 2022

👋 It looks like this issue has been open for 30 days with no activity. We'll mark this as stale for now, and wait 10 days for an update or for further comment before closing this issue out. If you think this issue needs to be prioritized, please comment to get the thread going again! Maintainers also review issues marked as stale on a regular basis and comment or adjust status if the issue needs to be reprioritized.

@github-actions
Copy link

As this issue has been inactive for more than one month, we will be closing it. Thank you to all the participants! If you would like to raise a related issue, please create a new issue which includes your specific details and references this issue number.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-triage-stale question M-T: User needs support to use the project
Projects
None yet
Development

No branches or pull requests

2 participants