Assistant listener middleware crashes when given a plain function

オープン
#1,597 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@sahiljagtap08 がすでに取り組んでいます。

2026年10月8日 から。

  • #1591 @sahiljagtap08 による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
30/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
python
領域
backend

調査の方向性

The bug is in Assistant.build_listener in slack_bolt/middleware/assistant/assistant.py and its async twin in async_assistant.py, which treat every middleware item as a Middleware instance and also mutate the caller's list with insert(0, ...). Compare with how App wraps plain functions in CustomMiddleware. Done when plain functions work as assistant middleware and the caller's list is left unchanged, with sync and async tests. A linked PR (#1591) already contains this fix, so check it before starting.

索引モデルが issue の本文から書いたものです。

説明

auto-triage-stale
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:

Pass a plain function as listener middleware on an Assistant listener.

from slack_bolt import App, Assistant

app = App(token="xoxb-...", signing_secret="secret")
assistant = Assistant()

def my_middleware(next):
    next()

@assistant.user_message(middleware=[my_middleware])
def handle(say):
    say("hi")

app.use(assistant)
  1. Register the listener above.
  2. Send a user message in an assistant thread.
Expected result:

The function is accepted as middleware, the same way @app.event(..., middleware=[my_middleware]) accepts it.

Actual result:

Every matching event fails with AttributeError: 'function' object has no attribute 'process'.

Assistant.build_listener in slack_bolt/middleware/assistant/assistant.py (and AsyncAssistant in async_assistant.py) treats every item in middleware as a Middleware instance. App wraps plain functions in CustomMiddleware, but the assistant does not. It also calls middleware.insert(0, ...) on the list the caller passed in, so the caller's list is changed.

I have a fix with sync and async tests in #1591.

Requirements

I have read the Contributing guidelines and Code of Conduct.

主要言語
Python
スター
1.3k
フォーク
300
平均マージ
19時間 33分
マージ済み PR(30日)
25

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

slackapi/bolt-python のほかの issue

slackapi/bolt-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。