出现该错误可能是因为Lambda函数返回的错误消息格式与API Gateway集成响应映射中指定的正则表达式不匹配。需要根据实际情况修改正则表达式或Lambda函数返回的错误消息格式以匹配集成响应映射中指定的正则表达式。
代码示例:
Lambda函数返回的错误消息格式:
{ "errorMessage": "Error processing request", "errorType": "InternalServerError" }
API Gateway集成响应映射中指定的正则表达式:
".errorMessage."
需要将API Gateway集成响应映射中指定的正则表达式修改为:
".*errorMessage.type."
或将Lambda函数返回的错误消息格式修改为:
{ "errorMessage": "Error processing request", "type": "InternalServerError" }