`WebClient` raises `JSONDecodeError` instead of `SlackApiError` on a malformed JSON body when retry handlers are set
I maintainer di solito rispondono entro 1 giorno
@agustin18 ci sta già lavorando.
Dal 19/11/2026.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 30/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Python
- Stelle
- 4k
- Fork
- 874
- Merge medio
- 13h 22m
- PR unite (30g)
- 64
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di slackapi/python-slack-sdk
-
SignatureVerifier.is_valid raises instead of returning False for a malformed timestamp, signature or bodyForse già presa @AmyScript l’ha presa 12 giorni fa. Apertabug security semver:patch
Difficoltà 2/5 1-3 ore Idoneità per principianti 57/100
slackapi/python-slack-sdk#2067 · 2 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 Mezza giornata Idoneità per principianti 42/100
slackapi/python-slack-sdk#2066 ·
I maintainer di solito rispondono entro 1 giorno
-
Add missing Web API methods that are documented on docs.slack.dev to WebClientForse già presa @zimeg l’ha presa 19 giorni fa. Apertaenhancement web-client
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
slackapi/python-slack-sdk#2014 · 2 commenti · 2 reazioni · 2 assegnatari ·
I maintainer di solito rispondono entro 1 giorno
-
Installation and Bot reject ISO 8601 timestamps with a negative UTC offset or a Z suffixForse già presa @hello-ashleyintech l’ha presa 44 giorni fa. Apertaauto-triage-stale bug
slackapi/python-slack-sdk#1989 · 2 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
chat_postMessage silently forwards thread_id to the API, so a threaded reply posts to the channelForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertaauto-triage-skip enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
slackapi/python-slack-sdk#1923 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di slackapi/python-slack-sdk
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
bad-antics/lateralus-lang#1623 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
fossguild/thelifesnake#82 ·
I maintainer di solito rispondono entro 1 giorno
-
Unfitted DialectClassifier crashes with a confusing ValueError: raise a clear "not fitted" errorApertagood first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
omarelshamy25x/shamy-arabic-nlp#111 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
pietbarber/Manage2Soar#1189 ·
I maintainer di solito rispondono entro 1 giorno
-
BUG: write_netcdf fails on Tutorial 3 BEM output with pandas CategoricalDtype DOF coordinatesForse già presa @dtgaebe l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
sandialabs/WecOptTool#467 ·