Repository navigation
fix(socket_mode): text acks starting with '{' were never sent - #1593
Open
sahiljagtap08 wants to merge 1 commit into
Open
sahiljagtap08 wants to merge 1 commit into
sahiljagtap08 wants to merge 1 commit into
Conversation
BoltResponse labels any body that starts with '{' as JSON. A text ack
such as ack('{foo') carries that label, so the Socket Mode adapters
called json.loads on it, raised JSONDecodeError, and never sent the
envelope response. Slack then showed a timeout to the user.
- Only send a JSON payload when the body really parses to an object;
otherwise send it as text
- Apply to both the sync and async adapters
- Add tests for a text ack that starts with '{' and a real JSON ack
Contributor
|
hi @sahiljagtap08! Thank you for taking the time to open this pull request 💟 can you open an issue regarding this instead? |
Contributor
Author
|
Sure, opened #1594 with the details. Thanks for taking a look! |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
BoltResponseguesses the content type from the body and labels anything that starts with{asapplication/json. A plain-text ack likeack("{foo")(for example a slash command that echoes user input) carries that label. The Socket Mode adapters trusted it and calledjson.loadson the body, which raisedJSONDecodeError. The envelope response was never sent, so Slack showed the user a timeout error.Changes in
slack_bolt/adapter/socket_mode/internals.pyandasync_internals.py:{"text": ...}, which is what the adapter already did for non-JSON bodies.Testing
Added
test_send_response_text_starting_with_bracetotests/adapter_tests/socket_mode/test_internals.pyand a newtests/adapter_tests_async/socket_mode/test_async_internals.py. Each sends a text body starting with{and a real JSON body through a fake client and checks the payload. Both fail onmainwithJSONDecodeErrorand pass with this change. Ran./scripts/format.sh,./scripts/lint.sh,./scripts/run_mypy.sh, and the sync and async Socket Mode test directories.Category
Requirements
./scripts/install_all_and_run_tests.shafter making the changes.Fixes #1594