Assistant listener middleware crashes when given a plain function
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 30/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Python
- Star
- 1.3k
- Fork
- 300
- Merge trung bình
- 19 giờ 33 phút
- Pull request đã merge (30 ngày)
- 25
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của slackapi/bolt-python
-
`extract_team_id` crashes with `TypeError when payload["user"]` is a string (e.g. `member_joined_channel` events)Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởauto-triage-skip bug security semver:major
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
slackapi/bolt-python#1447 · 9 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
auto-triage-stale
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
slackapi/bolt-python#1599 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Error handlers that take args: Args crash with a missing 'next' argumentCó thể đã có người làm @sahiljagtap08 đã nhận 42 ngày trước. Đang mởauto-triage-stale
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 25/100
slackapi/bolt-python#1598 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
AsyncOAuthFlow raises UnboundLocalError on org-wide install without a bot tokenCó thể đã có người làm @sahiljagtap08 đã nhận 42 ngày trước. Đang mởauto-triage-stale
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
slackapi/bolt-python#1596 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
SslCheck returns 401 for a matching verification_token and 200 for a wrong oneCó thể đã có người làm @sahiljagtap08 đã nhận 42 ngày trước. Đang mởauto-triage-stale
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 25/100
slackapi/bolt-python#1595 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của slackapi/bolt-python
Issue tương tự
-
documentation
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 74/100
BrainLesion/BraTS#200 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
OpenHands/extensions#970 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
rl-institut/enetra#91 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
huggingface/datasets#9100 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
NVIDIA/garak#2486 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày