Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SlackRequestHandler does not work on Lambda #132

Closed
cazziwork opened this issue Oct 29, 2020 · 6 comments · Fixed by #133
Closed

SlackRequestHandler does not work on Lambda #132

cazziwork opened this issue Oct 29, 2020 · 6 comments · Fixed by #133
Labels
area:adapter bug Something isn't working
Milestone

Comments

@cazziwork
Copy link

Problem

I was create app by bolt for python, And deploy on Lambda.
But It's not work correct.

I investigated this issue and found problems in determining the following areas.
https://github.com/slackapi/bolt-python/blob/main/slack_bolt/adapter/aws_lambda/handler.py
line:35
method = event.get("requestContext", {}).get("http", {}).get("method")

On my Lambda environment, it's always return None.

Workaround

I modified it below.
method = event.get("requestContext", {}).get("httpMethod", {})

It's work correct.

@seratch
Copy link
Member

seratch commented Oct 29, 2020

@cazziwork
Thanks for sharing this! I'd love to know more details as the current implementation surely works for me and we may miss some patterns we should cover.

Can you share more information (e.g, python runtime version you use, code snippet, the tool you use for deployments)?

@seratch seratch added this to the 0.9.6b0 milestone Oct 29, 2020
@cazziwork
Copy link
Author

@seratch
Thanks for your reply. I can provide information, of course.

Python Runtime: 3.8
Deploy tool: deployed zip file by browser
Lambda Handler Code Snippet:

import os
import sys
sys.path.insert(1, "vendor")

import logging
import secrets
import string

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
)

SlackRequestHandler.clear_all_log_handlers()
logging.basicConfig(format="%(asctime)s %(message)s", level=logging.DEBUG)

def lambda_handler(event, context):
    slack_handler = SlackRequestHandler(app=app)
    return slack_handler.handle(event, context)

@seratch
Copy link
Member

seratch commented Oct 29, 2020

@cazziwork Thanks for the prompt reply! In addition to that, can you share the info about your API Gateway? I haven't managed to reproduce your situation yet. If you enable a simple HTTP API as below, the requestContext is compatible with the current implementation of the adapter.

API type: HTTP
Authorization: NONE
Cross-origin resource sharing (CORS): No
Enable detailed metrics: No
Method: ANY
Resource path: /the-path-you-use
Stage: default

I'm happy to support the pattern you mentioned but just wanted to know what the pattern is.

seratch added a commit to seratch/bolt-python that referenced this issue Oct 29, 2020
@seratch seratch added the bug Something isn't working label Oct 29, 2020
@seratch
Copy link
Member

seratch commented Oct 29, 2020

I've checked Chalice's code and found the expected payload data structure is the same with your report. I've sent #133 to fix this and a new beta version will be released today.

@seratch
Copy link
Member

seratch commented Oct 29, 2020

I just released version 0.9.6b0. Try the version out when you have a chance! Thanks a lot for helping us fix this issue.

@cazziwork
Copy link
Author

cazziwork commented Oct 29, 2020

Thank you for your quick response.
I was confirmed that the issue is resolved by version 0.9.6b0!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:adapter bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants