I'm not sure if this is intended or not but it doesn't really seem like it. It looks like middleware is shared between listeners of the same type.
Reproducible in:
import os
from slack_bolt import App
app = App(
token=os.environ.get("SLACK_BOT_TOKEN"),
signing_secret=os.environ.get("SLACK_SIGNING_SECRET")
)
def test_middleware(logger, next):
logger.critical("We ran this middleware")
next()
@app.message("one", middleware=[test_middleware])
def one():
return
@app.message("two", middleware=[])
def two():
return
def main():
app.start(port=int(os.environ.get("PORT", 3000)))
if __name__ == "__main__":
main()
The slack_bolt version
slack-bolt==1.3.0
slack-sdk==3.3.0
Python runtime version
Python 3.8.3
OS info
ProductName: Mac OS X
ProductVersion: 10.15.7
BuildVersion: 19H2
Darwin Kernel Version 19.6.0: Mon Aug 31 22:12:52 PDT 2020; root:xnu-6153.141.2~1/RELEASE_X86_64
Steps to reproduce:
(Share the commands to run, source code, and project settings (e.g., setup.py))
- Start up the app
- Type one into slack
- You will see in the logs that it will run test_middleware by logging "We ran this middleware"
- Type two into slack
- You will see in the logs that that it will run test_middleware by logging "We ran this middleware"
Expected result:
The middleware test_middleware will only run when the user types in one as that has specified that middleware and two
has not specified that middleware
Actual result:
The middleware will on both listeners as you can see it logs from both message listeners.
I have also noted if that you switch the order of them and load the first listener in without the middleware this issue will not happen. It seems to be saving it and or not resetting the middleware.
Requirements
Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.
I'm not sure if this is intended or not but it doesn't really seem like it. It looks like middleware is shared between listeners of the same type.
Reproducible in:
The
slack_boltversionslack-bolt==1.3.0
slack-sdk==3.3.0
Python runtime version
Python 3.8.3
OS info
ProductName: Mac OS X
ProductVersion: 10.15.7
BuildVersion: 19H2
Darwin Kernel Version 19.6.0: Mon Aug 31 22:12:52 PDT 2020; root:xnu-6153.141.2~1/RELEASE_X86_64
Steps to reproduce:
(Share the commands to run, source code, and project settings (e.g., setup.py))
Expected result:
The middleware test_middleware will only run when the user types in one as that has specified that middleware and two
has not specified that middleware
Actual result:
The middleware will on both listeners as you can see it logs from both message listeners.
I have also noted if that you switch the order of them and load the first listener in without the middleware this issue will not happen. It seems to be saving it and or not resetting the middleware.
Requirements
Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.