Check whether the request is being instrumented or not directly from the context variables to prevent missing the changes in case of a "chunked" transfer encoding which does not use the method we instrument in older versions of the library.
Testing done
Unit and integration tests are green
I've reproduced the issue on my AWS account and confirmed that this indeed fixes the issue. Using slack-bot with the following code:
import os
# Slack bolt
from slack_bolt import App
from slack_bolt.adapter.aws_lambda import SlackRequestHandler
# Set up the bolt application
app = App(
process_before_response = True,
token = os.environ['SLACK_BOT_TOKEN'],
signing_secret = os.environ['SLACK_SIGNING_SECRET']
)
# Acknowledge incoming slack command
def acknowledge_command(body, ack):
# Acknowledge command
if (body_text := body.get('text')) is None or body_text.strip() == '':
ack(f':x: `{body.get("command")}` needs more context')
# Got command, no response
ack()
# Actual processing of the command
def process_command(respond, body):
respond(f'Completed! (task: {body.get("command")})')
# Register command with application
app.command('/test')(
ack = acknowledge_command,
lazy = [process_command]
)
# Set up lambda function
def handler(event, context):
import json
print(json.dumps(event))
return SlackRequestHandler(app=app).handle(event, context)
Description
Testing done
serverless.yml
Slack bot works fine