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

Ouverte
#1,598 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

@sahiljagtap08 y travaille déjà.

Depuis le 8/10/2026.

  • #1592 par @sahiljagtap08 — ouverte

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
25/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
python
Domaine
backend

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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.

Langage dominant
Python
Étoiles
1.3k
Forks
300
Merge moyen
19 h 33 min
PR mergées (30 j)
25

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de slackapi/bolt-python

Toutes les issues de slackapi/bolt-python

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.