slackapi / slackapi/python-slack-sdk
SlackApiError cannot be unpickled
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 4k
- フォーク
- 857
- 平均マージ
- 22時間 21分
- マージ済み PR(30日)
- 16
説明
SlackApiError raises an error when trying to unpickle it.
This is particularly annoying in a Celery task since another bug in celery will cause the whole worker node to fail.
The Slack SDK version
2.9.4
Python runtime version
3.11.0
OS info
ProductName: macOS
ProductVersion: 13.0
BuildVersion: 22A380
Darwin Kernel Version 22.1.0: Sun Oct 9 20:15:09 PDT 2022; root:xnu-8792.41.9~2/RELEASE_ARM64_T6000
Steps to reproduce:
import pickle
from slack.errors import SlackApiError
e = SlackApiError("Internal server error", "<response>")
dumped = pickle.dumps(e)
pickle.loads(dumped)
Expected result:
No error.
Actual result:
Traceback (most recent call last):
File "/private/tmp/pickle_exc/bug.py", line 7, in <module>
pickle.loads(dumped)
TypeError: SlackApiError.__init__() missing 1 required positional argument: 'response'
Solution
The SlackApiError could be implemented in such a way that the constructor accepts only the message, and the response defaults to None. Then the string representation can be delegated to __str__:
class SlackApiError(Exception):
def __init__(self, message, response=None):
super().__init__(message)
self.response = response
def __str__(self):
return f"{self.args[0]}\nThe server responded with: {self.response}"
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
SlackApiError の定義から始め、issue に示されている pickle の再現を Python 3.11 で実行します。例外がどのように初期化され、表現されるかを確認し、その後、pickling と unpickling によってメッセージとレスポンスが保持され、TypeError が発生しないことを検証します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- api
- issue の種類
- バグ
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 45/100