`WebClient` raises `JSONDecodeError` instead of `SlackApiError` on a malformed JSON body when retry handlers are set
メンテナーはふだん 1 日以内に返信
@agustin18 がすでに取り組んでいます。
2026年11月19日 から。
評価
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- Python
- スター
- 4k
- フォーク
- 874
- 平均マージ
- 13時間 22分
- マージ済み PR(30日)
- 64
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
slackapi/python-slack-sdk のほかの issue
-
SignatureVerifier.is_valid raises instead of returning False for a malformed timestamp, signature or body対応中かも @AmyScript が 12 日前に担当しました。 オープンbug security semver:patch
難易度 2/5 1〜3時間 初心者へのやさしさ 57/100
slackapi/python-slack-sdk#2067 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 半日 初心者へのやさしさ 42/100
slackapi/python-slack-sdk#2066 ·
メンテナーはふだん 1 日以内に返信
-
Add missing Web API methods that are documented on docs.slack.dev to WebClient対応中かも @zimeg が 19 日前に担当しました。 オープンenhancement web-client
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
slackapi/python-slack-sdk#2014 · コメント 2 件 · リアクション 2 件 · 担当者 2 名 ·
メンテナーはふだん 1 日以内に返信
-
Installation and Bot reject ISO 8601 timestamps with a negative UTC offset or a Z suffix対応中かも @hello-ashleyintech が 44 日前に担当しました。 オープンauto-triage-stale bug
slackapi/python-slack-sdk#1989 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
chat_postMessage silently forwards thread_id to the API, so a threaded reply posts to the channel再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンauto-triage-skip enhancement
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
slackapi/python-slack-sdk#1923 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
slackapi/python-slack-sdk の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
bad-antics/lateralus-lang#1623 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
fossguild/thelifesnake#82 ·
メンテナーはふだん 1 日以内に返信
-
Unfitted DialectClassifier crashes with a confusing ValueError: raise a clear "not fitted" errorオープンgood first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
omarelshamy25x/shamy-arabic-nlp#111 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
pietbarber/Manage2Soar#1189 ·
メンテナーはふだん 1 日以内に返信
-
BUG: write_netcdf fails on Tutorial 3 BEM output with pandas CategoricalDtype DOF coordinates対応中かも @dtgaebe が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
sandialabs/WecOptTool#467 ·