`WebClient` raises `JSONDecodeError` instead of `SlackApiError` on a malformed JSON body when retry handlers are set
Mantenedores costumam responder em até 1 dia
@agustin18 já está trabalhando nisso.
Desde 19/11/2026.
Avaliação
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Facilidade para iniciantes
- 30/100
Direção de pesquisa
Start by reading _perform_urllib_http_request and _urllib_api_call, then inspect the tests covering malformed response bodies and retry handlers. Reproduce the provided WebClient example and compare it with WebClient(retry_handlers=[]). Done means malformed JSON follows the existing fallback and raises SlackApiError; consider whether _request_for_pagination needs the same treatment, as the issue notes.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Reproducible in
slack_sdkv3.20.0 through v3.47.0 (and currentmain)- Sync
WebClientwith retry handlers set (the default)
Steps to reproduce
from unittest.mock import patch
from slack_sdk import WebClient
client = WebClient(token="xoxb-test")
response = {"status": 200, "headers": {}, "body": '{"ok": tru'}
with patch.object(client, "_perform_urllib_http_request_internal", return_value=response):
client.api_test()
Expected result
A SlackApiError whose response["error"] starts with Received a response in a non-JSON format. That is what WebClient(retry_handlers=[]), AsyncWebClient, and v3.19.5 and earlier raise for the same body.
Actual result
json.decoder.JSONDecodeError: Expecting value: line 1 column 8 (char 7), logged at ERROR as Failed to send a request to Slack API server.
Cause
#1334 (v3.20.0) added a json.loads to the retry loop in _perform_urllib_http_request. It parses any 200 body that starts with { and has no guard. A decode error escapes through the except Exception branch before the graceful fallback in _urllib_api_call runs. Bodies that don't start with {, and clients without retry handlers, still get SlackApiError.
Proposed fix
Catch JSONDecodeError in that retry-branch parse and leave parsed_body unset. _urllib_api_call then takes its existing fallback. About 3 lines plus a test.
Why 4.x
This has shipped since v3.20.0, so callers may catch JSONDecodeError or ValueError around sync calls. Changing the raised type would break them. _request_for_pagination also raises JSONDecodeError on a malformed body, with or without handlers, so it's worth deciding there in the same change.
- Linguagem predominante
- Python
- Estrelas
- 4k
- Forks
- 874
- Merge médio
- 13h 22min
- PRs com merge (30d)
- 64
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de slackapi/python-slack-sdk
-
SignatureVerifier.is_valid raises instead of returning False for a malformed timestamp, signature or bodyTalvez já em andamento @AmyScript assumiu há 12 dias. Abertabug security semver:patch
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 57/100
slackapi/python-slack-sdk#2067 · 2 comentários · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 3/5 Meio dia Facilidade para iniciantes 42/100
slackapi/python-slack-sdk#2066 ·
Mantenedores costumam responder em até 1 dia
-
Add missing Web API methods that are documented on docs.slack.dev to WebClientTalvez já em andamento @zimeg assumiu há 19 dias. Abertaenhancement web-client
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 35/100
slackapi/python-slack-sdk#2014 · 2 comentários · 2 reações · 2 responsáveis ·
Mantenedores costumam responder em até 1 dia
-
Installation and Bot reject ISO 8601 timestamps with a negative UTC offset or a Z suffixTalvez já em andamento @hello-ashleyintech assumiu há 44 dias. Abertaauto-triage-stale bug
slackapi/python-slack-sdk#1989 · 2 comentários · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
chat_postMessage silently forwards thread_id to the API, so a threaded reply posts to the channelTalvez livre de novo Um pull request para esta issue foi fechado sem ser mesclado. Abertaauto-triage-skip enhancement
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 48/100
slackapi/python-slack-sdk#1923 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
Todas as issues de slackapi/python-slack-sdk
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
plone/plone.observability#114 ·
Mantenedores costumam responder em até 1 dia
-
area:docs type:docs
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
jejjohnson/gauss_flows#246 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
openvax/varcode#824 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Add SAS as a cable typeAbertanetbox status: needs triage type: feature
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
netbox-community/netbox#23868 ·
Mantenedores costumam responder em até 2 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
emeryberger/CSrankings#15757 ·
Mantenedores costumam responder em até 9 dias