Skip to content

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

Description

@sahiljagtap08

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions