Socket Mode: ack() with text starting with '{' is never sent (JSONDecodeError)
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 25/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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()
- Start the app in Socket Mode.
- Run
/helloin 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.
- Lenguaje dominante
- Python
- Estrellas
- 1.3k
- Forks
- 300
- Merge medio
- 19 h 33 min
- PR fusionados (30 d)
- 25
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de slackapi/bolt-python
-
`extract_team_id` crashes with `TypeError when payload["user"]` is a string (e.g. `member_joined_channel` events)Posiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertoauto-triage-skip bug security semver:major
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
slackapi/bolt-python#1447 · 9 comentarios ·
Los mantenedores suelen responder en 1 día
-
auto-triage-stale
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
slackapi/bolt-python#1599 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Error handlers that take args: Args crash with a missing 'next' argumentPosiblemente ocupada @sahiljagtap08 la tomó hace 42 días. Abiertoauto-triage-stale
Dificultad 3/5 1-2 días Aptitud para principiantes 25/100
slackapi/bolt-python#1598 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Assistant listener middleware crashes when given a plain functionPosiblemente ocupada @sahiljagtap08 la tomó hace 42 días. Abiertoauto-triage-stale
Dificultad 2/5 1-3 horas Aptitud para principiantes 30/100
slackapi/bolt-python#1597 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
AsyncOAuthFlow raises UnboundLocalError on org-wide install without a bot tokenPosiblemente ocupada @sahiljagtap08 la tomó hace 42 días. Abiertoauto-triage-stale
Dificultad 2/5 1-3 horas Aptitud para principiantes 35/100
slackapi/bolt-python#1596 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de slackapi/bolt-python
Issues similares
-
documentation
Dificultad 1/5 Menos de una hora Aptitud para principiantes 74/100
BrainLesion/BraTS#200 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
OpenHands/extensions#970 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
rl-institut/enetra#91 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
huggingface/datasets#9100 ·
Los mantenedores suelen responder en 1 día
-
needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
NVIDIA/garak#2486 · 1 comentario ·
Los mantenedores suelen responder en 2 días