Error handlers that take args: Args crash with a missing 'next' argument

Đang mở
#1,598 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@sahiljagtap08 đang làm issue này rồi.

Từ ngày 8/10/2026.

  • #1592 của @sahiljagtap08 — đang mở

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
25/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
backend

Hướng nghiên cứu

The crash comes from slack_bolt/kwargs_injection/utils.py in build_required_kwargs and its async twin in async_utils.py, where next is removed from the args before Args(**all_available_args) is built and arg_names.pop() shrinks the listener's list. Read both functions and reproduce with the snippet in the issue using an @app.error handler that takes args: Args. Done means the handler runs and logs the original RuntimeError in sync and async paths; a fix is already open as PR #1592, so review or extend that rather than starting a parallel one.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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:

Register a global error handler that takes args: Args.

from slack_bolt import App, Args

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

@app.error
def on_error(error, args: Args):
    args.logger.error(error)

@app.event("app_mention")
def boom(say):
    raise RuntimeError("original error")
  1. Trigger the app_mention event.
Expected result:

on_error runs and logs original error.

Actual result:

The error handler itself crashes before it runs:

TypeError: Args.__init__() missing 1 required positional argument: 'next'

The original RuntimeError is lost. In slack_bolt/kwargs_injection/utils.py (build_required_kwargs) and async_utils.py, next is removed from the available arguments for error handlers, but Args(**all_available_args) is then built from that reduced dict, and Args requires next. The same code also uses arg_names.pop() on the listener's own list, so the list shrinks on every call.

I have a fix with sync and async tests in #1592. It also adds an error field to Args so error handlers can read the exception through args.

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

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của slackapi/bolt-python

Tất cả issue của slackapi/bolt-python

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.