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

Aperta
#1,598 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@sahiljagtap08 ci sta già lavorando.

Dal 8/10/2026.

  • #1592 di @sahiljagtap08 — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
backend

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Python
Stelle
1.3k
Fork
300
Merge medio
19h 33m
PR unite (30g)
25

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di slackapi/bolt-python

Tutte le issue di slackapi/bolt-python

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.