简体   繁体   English

AWS Lambda:函数已成功创建,但在创建触发器时出错:无法读取未定义的属性“包含”

[英]AWS Lambda: function was created successfully but an error occurred when creating the trigger: Cannot read property 'includes' of undefined

I am trying to create a Lambda function off of the AWS-managed slack-echo-command-python blueprint and whenever I hit create, it comes back with "Your Lambda function "test_lambda_01" was successfully created, but an error occurred when creating the trigger: Cannot read property 'includes' of undefined."我正在尝试从 AWS 管理的 slack-echo-command-python 蓝图创建一个 Lambda 函数,每当我点击创建时,它都会返回“您的 Lambda 函数“test_lambda_01”已成功创建,但在创建时出现错误触发器:无法读取未定义的属性“包含”。” I am not sure what this means.我不确定这意味着什么。

The trigger is supposed to be an AWS API Gateway that is created and attached automatically.触发器应该是自动创建和附加的 AWS API 网关。 I have tried to go create one through the Management Console and then add it to the triggers on the Lambda function manually.我尝试通过管理控制台创建一个,然后手动将其添加到 Lambda 函数上的触发器中。 It gets added successfully but I get back "502_service_error" when I try to use my Slack slash command.它已成功添加,但当我尝试使用 Slack 斜杠命令时,我返回“502_service_error”。 It currently is supposed to accept all call types by default (will change later but I want to get something working).它目前应该默认接受所有呼叫类型(稍后会更改,但我想让一些工作正常进行)。

I have changed the endpoint in the Slack settings to the correct one.我已将 Slack 设置中的端点更改为正确的端点。 I can see it being called in the CloudWatch metrics.我可以看到它在 CloudWatch 指标中被调用。

I edited the Lambda Function code to return this on every call, just for testing purposes.我编辑了 Lambda 函数代码以在每次调用时返回它,仅用于测试目的。 I am 99% sure that this is a valid response to give to Slack as most/all of it was copied from an example.我 99% 确信这是对 Slack 的有效回应,因为大部分/全部内容都是从示例中复制的。 It is valid JSON according to https://jsonlint.com/ .根据https://jsonlint.com/,它是有效的 JSON。

{
    "body": {
        "blocks": [{
                "text": {
                    "text": "*It's 80 degrees right now.*",
                    "type": "mrkdwn"
                },
                "type": "section"
            },
            {
                "text": {
                    "text": "Partly cloudy today and tomorrow",
                    "type": "mrkdwn"
                },
                "type": "section"
            }
        ],
        "response_type": "ephemeral"
    },
    "headers": {
        "Content-Type": "application/json"
    },
    "statusCode": "200"
}

I have tested the Lambda Function with their default test and it returns the above.我已经用他们的默认测试测试了 Lambda 函数,它返回了上述内容。 The API Gateway appears under the triggers. API 网关出现在触发器下方。 Do I need to attach more permissions to the API Gateway (it already has permission to invoke the lambda function)?我是否需要为 API 网关附加更多权限(它已经拥有调用 lambda 函数的权限)? Also, what was I doing incorrectly when trying to create the function from the blueprint?另外,在尝试从蓝图创建函数时,我做错了什么?

Please let me know if you want any additional information.如果您需要任何其他信息,请告诉我。

You need to stringify the body parameter in the response.您需要对响应中的body参数进行字符串化。

https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html

{
    "isBase64Encoded": true|false,
    "statusCode": httpStatusCode,
    "headers": { "headerName": "headerValue", ... },
    "multiValueHeaders": { "headerName": ["headerValue", "headerValue2", ...], ... },
    "body": "..."
}

if you see the body parameter above, it is a string.如果你看到上面的body参数,它是一个字符串。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 python boto3 aws lambda - 调用 StartInstances 操作时发生错误 (IncorrectInstanceState): - python boto3 aws lambda - An error occurred (IncorrectInstanceState) when calling the StartInstances operation: 如何解决“无法读取未定义的属性'字段'” - How to resolve “Cannot read property 'fields' of undefined” 将AccessToken推送到AWS Lambda函数 - Push AccessToken to AWS Lambda Function lambda客户端调用函数并从MQ读取json消息并将其发送到AWS Kinesis - lambda client invoke function and read json messages from MQ and send to AWS Kinesis 如何在aws lambda python函数中读取和验证在s3中上传的csv中的标头 - How to read and validate header in csv uploaded in s3 in aws lambda python function 无法在 AWS Lambda 上使用请求模块 - Cannot use Requests-Module on AWS Lambda Django1.8和Python2.7:未捕获的TypeError:无法读取未定义的属性“ 0”(…) - Django1.8 and Python2.7: Uncaught TypeError: Cannot read property '0' of undefined(…) 从云Lambda函数调用本地AWS Lambda函数 - Invoking local AWS Lambda function from a cloud Lambda function 错误 Lambda 函数处理程序 - Error Lambda Function handler 从Python 2.7上的现有lambda函数调用AWS lambda函数 - Call AWS lambda function from an existing lambda function on Python 2.7
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM