Skip to content

fix(socket_mode): text acks starting with '{' were never sent - #1593

Open
sahiljagtap08 wants to merge 1 commit into
slackapi:mainfrom
sahiljagtap08:fix/socket-mode-text-ack-starting-with-brace
Open

sahiljagtap08 wants to merge 1 commit into
slackapi:mainfrom
sahiljagtap08:fix/socket-mode-text-ack-starting-with-brace

Conversation

@sahiljagtap08

@sahiljagtap08 sahiljagtap08 commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

BoltResponse guesses the content type from the body and labels anything that starts with { as application/json. A plain-text ack like ack("{foo") (for example a slash command that echoes user input) carries that label. The Socket Mode adapters trusted it and called json.loads on the body, which raised JSONDecodeError. The envelope response was never sent, so Slack showed the user a timeout error.

Changes in slack_bolt/adapter/socket_mode/internals.py and async_internals.py:

  • A body is sent as a JSON payload only when it actually parses to a JSON object. Anything else is sent as {"text": ...}, which is what the adapter already did for non-JSON bodies.
  • The same helper is used in both the sync and async adapters.

Testing

Added test_send_response_text_starting_with_brace to tests/adapter_tests/socket_mode/test_internals.py and a new tests/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 on main with JSONDecodeError and 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

  • slack_bolt.App and/or its core components
  • slack_bolt.async_app.AsyncApp and/or its core components
  • Adapters in slack_bolt.adapter
  • Others

Requirements

  • I've read and understood the Contributing Guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've run ./scripts/install_all_and_run_tests.sh after making the changes.

Fixes #1594

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
@sahiljagtap08
sahiljagtap08 requested a review from a team as a code owner October 8, 2026 21:50
@srtaalej

srtaalej commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

hi @sahiljagtap08! Thank you for taking the time to open this pull request 💟 can you open an issue regarding this instead?

@sahiljagtap08

Copy link
Copy Markdown
Contributor Author

Sure, opened #1594 with the details. Thanks for taking a look!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Socket Mode: ack() with text starting with '{' is never sent (JSONDecodeError)

2 participants