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

オープン
#1,594 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@sahiljagtap08 がすでに取り組んでいます。

2026年10月8日 から。

  • #1593 @sahiljagtap08 による — オープン

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
python
領域
backend

調査の方向性

The JSON parse happens in send_response in slack_bolt/adapter/socket_mode/internals.py and in send_async_response in async_internals.py, where a body starting with { is passed to json.loads without error handling. Read those two functions, then reproduce with an ack string such as "{curly braces". Done means both paths fall back to sending the text as a plain string instead of raising. A fix already exists in open PR #1593, so check that thread before starting new work.

索引モデルが issue の本文から書いたものです。

説明

auto-triage-stale
Reproducible in:
The slack_bolt version
slack_bolt==1.30.0
slack_sdk==3.45.0
Python runtime version
Python 3.12.5
OS info
macOS 27.0
Steps to reproduce:

In Socket Mode, call ack() with a plain text string that starts with { but is not valid JSON.

import os
from slack_bolt import App
from slack_bolt.adapter.socket_mode import SocketModeHandler

app = App(token=os.environ["SLACK_BOT_TOKEN"])

@app.command("/hello")
def hello(ack):
    ack("{curly braces are fun}")

SocketModeHandler(app, os.environ["SLACK_APP_TOKEN"]).start()
  1. Start the app in Socket Mode.
  2. Run /hello in Slack.
Expected result:

Slack receives the ack and shows the text {curly braces are fun} as the response.

Actual result:

The ack is never sent. Slack shows "failed with the error operation_timeout" and the app logs a json.JSONDecodeError.

The cause is in slack_bolt/adapter/socket_mode/internals.py (send_response) and async_internals.py (send_async_response). They decide the ack body is JSON by checking whether the text starts with {, and then call json.loads() on it without handling a parse failure:

if content_type.startswith("application/json"):
    payload = json.loads(bolt_resp.body)

BoltResponse sets Content-Type: application/json for any string body that starts with {, so the same problem happens with ack("{", ...), ack("{foo"), or any text that happens to begin with that character. The non-Socket-Mode HTTP path does not have this issue because the body is sent through as-is.

I have a fix ready in #1593 that falls back to sending the string as {"text": body} whenever it cannot be parsed as a JSON object. Opening this issue at the maintainers' request so it can be tracked.

Requirements

I have read the Contributing guidelines and Code of Conduct.

主要言語
Python
スター
1.3k
フォーク
300
平均マージ
19時間 33分
マージ済み PR(30日)
25

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

slackapi/bolt-python のほかの issue

slackapi/bolt-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。