Assistant listener middleware crashes when given a plain function
维护者通常 1 天内回复
评估
调研方向
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 内容生成。
描述
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)
- Register the listener above.
- 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 分钟
- 30 天内合并 PR
- 25
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
slackapi/bolt-python 的其他 Issue
-
`extract_team_id` crashes with `TypeError when payload["user"]` is a string (e.g. `member_joined_channel` events)可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭auto-triage-skip bug security semver:major
难度 2/5 1-3 小时 新手友好度 72/100
slackapi/bolt-python#1447 · 9 条评论 ·
维护者通常 1 天内回复
-
auto-triage-stale
难度 5/5 一周以上 新手友好度 35/100
slackapi/bolt-python#1599 · 1 条评论 ·
维护者通常 1 天内回复
-
Error handlers that take args: Args crash with a missing 'next' argument可能已有人在做 @sahiljagtap08 于 42 天前认领。 未关闭auto-triage-stale
难度 3/5 1-2 天 新手友好度 25/100
slackapi/bolt-python#1598 · 1 条评论 ·
维护者通常 1 天内回复
-
AsyncOAuthFlow raises UnboundLocalError on org-wide install without a bot token可能已有人在做 @sahiljagtap08 于 42 天前认领。 未关闭auto-triage-stale
难度 2/5 1-3 小时 新手友好度 35/100
slackapi/bolt-python#1596 · 1 条评论 ·
维护者通常 1 天内回复
-
SslCheck returns 401 for a matching verification_token and 200 for a wrong one可能已有人在做 @sahiljagtap08 于 42 天前认领。 未关闭auto-triage-stale
难度 2/5 1-3 小时 新手友好度 25/100
slackapi/bolt-python#1595 · 1 条评论 ·
维护者通常 1 天内回复
查看 slackapi/bolt-python 的全部 Issue
相似的 Issue
-
documentation
难度 1/5 1 小时以内 新手友好度 74/100
BrainLesion/BraTS#200 ·
-
难度 2/5 1-3 小时 新手友好度 76/100
OpenHands/extensions#970 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
rl-institut/enetra#91 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
huggingface/datasets#9100 ·
维护者通常 1 天内回复
-
needs-triage
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 2 天内回复