Assistant listener middleware crashes when given a plain function

Aperta
#1,597 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.

  • #1591 di @sahiljagtap08 — aperta

Valutazione

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

Direzione di ricerca

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.

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:

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)
  1. Register the listener above.
  2. 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.

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.