Process in custom workflow step return token revoked and Function failed to execute error
I deployed my slack bolt python code on AWS Lambda with HTTP API Gateway, and have an org access level slack app installed in my organization workspace. I have processes triggering with command, action, view working perfectly fine, except for custom workflow step(function).
When I trigger my workflow that contain my app custom workflow step, my Lambda can receive it and process the process. But any Slack API request running with the WebClient, Fail, Complete passed in the parameter, will return token revoked error and receive Function failed to execute error notification from Slackbot. It happen even if I run almost nothing in the process.
The weird part is, if I trigger the workflow multiple times, sometimes it will running without any problem. And If I create a new WebClient instance with the same token inside my process, instead of using client from the parameter, it will run perfectly fine, but Slackbot will still report Function failed to execute error notification.
This problem only happen with process triggered with custom workflow step. I think this is a bug but is there anything I can try for fixing this? Thanks.
Reproducible in:
The slack_bolt version
slack_bolt==1.23.0 slack_sdk==3.35.0
Python runtime version
Python 3.13.3
OS info
arm64(AWS Lambda)
Steps to reproduce:
- Deploy slack bolt python code to AWS lambda with HTTP API Gateway
import os
from slack_bolt import App
from slack_bolt.adapter.aws_lambda import SlackRequestHandler
app = App(
signing_secret=os.environ.get("SLACK_SIGNING_SECRET"),
token=os.environ.get("SLACK_BOT_TOKEN"),
process_before_response=True,
)
def ack_step(ack):
ack()
def testlazy(complete):
complete() # also happened when I use return instead
# workflow step
app.function("step_test")(
ack=ack_step,
lazy=[testlazy],
)
# AWS Lambda entrypoint
def handler(event, context):
slack_handler = SlackRequestHandler(app=app)
return slack_handler.handle(event, context)
- Create a slack app with workflow step, step_test as callback ID
- Trigger a link triggered workflow that include custom workflow step of step_test multiple times
Expected result:
- Finish process without Slack reporting Function failed to execute error.
- WebClient instance from parameter can run Slack API without token_revoked error
Actual result:
- Slack reporting Function failed to execute error most of the time.
- WebClient instance from parameter return token_revoked error while running any Slack API most of the time.
-
Failed to run an internal function (The request to the Slack API failed. (url: https://slack.com/api/functions.completeSuccess)
-
The server responded with: {'ok': False, 'error': 'token_revoked'})
-
Hey @ccn-siu-chunlok! 👋
This is an interesting issue since the errors returned aren't so consistent and I haven't found the same error in quick testing so far 🤖
I hope to explore this more, but I'm first wondering how soon after the function_executed event begins is the call made to the complete function? From the snippet above it seems soon, but for context I want to share that workflow steps use a token specific to each invocation that expires after a short time or function completion:
📚 https://docs.slack.dev/authentication/tokens#wfb
If these events aren't acknowledged soon, the function execution error might revoke this token 🤔
I'm also wondering if debug logs for these invocations, both failing and successful, are available? In a local setup the following appears for me:
DEBUG:slack_bolt.App:Applying slack_bolt.middleware.attaching_function_token.attaching_function_token.AttachingFunctionToken
DEBUG:slack_bolt.App:Checking listener: ack_step ...
DEBUG:slack_bolt.App:Running listener: ack_step ...
DEBUG:slack_bolt.App:Running lazy listener: testlazy ...
DEBUG:slack_bolt.App:Responding with status: 200 body: "" (0 millis)
And I'm wanting to confirm these are appearing in the expected order before the lazy function is called?
I'm first wondering how soon after the function_executed event begins is the call made to the complete function?
the function_executed happened just right after I trigger the workflow and error occurred after few seconds
2025-05-23 16:45:21[Error]Function Test execution result
2025-05-23 16:45:17[Info]Function Test execution started
I'm also wondering if debug logs for these invocations, both failing and successful, are available? And I'm wanting to confirm these are appearing in the expected order before the lazy function is called?
Yes, I have tracked down both failing and successful log for my Lambda. The slack_bolt debug log order seems to be correct and same in both log.
Here a failed log of my Lambda:
1747992281531,"INIT_START Runtime Version: python:3.13.v40 ...
1747992284054,"[DEBUG] 2025-05-23T09:24:44.054Z Sending a request - url: https://slack.com/api/auth.test...
1747992284054,"2025-05-23 09:24:44 169.254.18.59 slack_bolt.App[2] DEBUG Sending a request - url: https://slack.com/api/auth.test...
1747992284265,"[DEBUG] 2025-05-23T09:24:44.265Z Received the following response - status: 200...
1747992284265,"2025-05-23 09:24:44 169.254.18.59 slack_bolt.App[2] DEBUG Received the following response - status: 200...
1747992284272,"START RequestId: 74155c56-168a-4858-9c6e-ea1dad641536 Version: $LATEST
...
1747992284274,"2025-05-23 09:24:44 169.254.18.59 slack_bolt.App[2] DEBUG Applying slack_bolt.middleware.attaching_function_token.attaching_function_token.AttachingFunctionToken
1747992284275,"2025-05-23 09:24:44 169.254.18.59 slack_bolt.App[2] DEBUG Checking listener: ack_step ...
1747992284275,"2025-05-23 09:24:44 169.254.18.59 slack_bolt.App[2] DEBUG Running listener: ack_step ...
1747992284275,"2025-05-23 09:24:44 169.254.18.59 slack_bolt.App[2] DEBUG Running lazy listener: testlazy ...
...
1747992286288,"2025-05-23 09:24:46 169.254.18.59 slack_bolt.App[2] DEBUG Responding with status: 200 body: """" (2013 millis)
1747992286294,"END RequestId: 74155c56-168a-4858-9c6e-ea1dad641536
1747992286295,"REPORT RequestId: 74155c56-168a-4858-9c6e-ea1dad641536 Duration: 2022.33 ms Billed Duration: 2023 ms Memory Size: 128 MB Max Memory Used: 115 MB Init Duration: 2736.05 ms
1747992286342,"START RequestId: 68af0abb-f153-47d5-a0cd-2a30374e876b Version: $LATEST
1747992286579,"Failed to run an internal function (The request to the Slack API failed. (url: https://slack.com/api/functions.completeSuccess)
1747992286579,"The server responded with: {'ok': False, 'error': 'token_revoked'})
1747992286594,"END RequestId: 68af0abb-f153-47d5-a0cd-2a30374e876b
1747992286594,"REPORT RequestId: 68af0abb-f153-47d5-a0cd-2a30374e876b Duration: 250.95 ms Billed Duration: 251 ms Memory Size: 128 MB Max Memory Used: 115 MB
Bt the way, I have no problems at all when I test my code with socket mode locally. This workflow step problem only occurring on AWS Lambda. Is there any Lambda settings I need to check to make it work?
👋 It looks like this issue has been open for 30 days with no activity. We'll mark this as stale for now, and wait 10 days for an update or for further comment before closing this issue out. If you think this issue needs to be prioritized, please comment to get the thread going again! Maintainers also review issues marked as stale on a regular basis and comment or adjust status if the issue needs to be reprioritized.
As this issue has been inactive for more than one month, we will be closing it. Thank you to all the participants! If you would like to raise a related issue, please create a new issue which includes your specific details and references this issue number.