dmack
July 25, 2024, 11:46am
1
Hi team,
I am using an API gateway connected to a Lambda function.
The Lambda function response is returning:
Response
{
“statusCode”: 400,
“body”: “{"errorType":"UserLambdaValidationException","message":"PreSignUp failed with error [UserAlreadyExists] Registration failed. A user with that email already exists…"}”
}
Lambda Error Regex: .“errorType”:“UserLambdaValidationException”.
Yet when I test via API gateway or Postman it is still returning a 200 OK response.
I have tried a variety of different response formats and regex combinations.
Any suggestions or ideas?
Thank you,
David
could you share your yml file?
dmack
July 26, 2024, 10:29am
3
Hi, I am using AWS Console
dmack
July 27, 2024, 2:57am
4
Thanks for your reply. I have exported my current config… please see below and let me know if you have any thoughts or feedback.
/register:
post:
produces:
- "application/json"
responses:
"200":
description: "200 response"
schema:
$ref: "#/definitions/Empty"
headers:
Access-Control-Allow-Origin:
type: "string"
"400":
description: "400 response"
schema:
$ref: "#/definitions/Empty"
headers:
Access-Control-Allow-Origin:
type: "string"
x-amazon-apigateway-integration:
type: "aws"
httpMethod: "POST"
uri: "arn:aws:apigateway:ap-southeast-2:lambda:path/2015-03-31/functions/arn:aws:lambda:ap-southeast-2:<ACCOUNT_ID>:function:<FUNCTION NAME>/invocations"
responses:
default:
statusCode: "200"
".*\"errorType\":\"UserLambdaValidationException\".*":
statusCode: "400"
responseParameters:
method.response.header.Access-Control-Allow-Origin: "'*'"
responseTemplates:
application/json: "#set($inputRoot = $input.path('$'))\r\n{\r\n \"\
statusCode\": \"$inputRoot.statusCode\",\r\n \"body\": $input.json('$.body')\r\
\n}\r\n"
passthroughBehavior: "when_no_match"
contentHandling: "CONVERT_TO_TEXT"
definitions:
Empty:
type: "object"
title: "Empty Schema"
x-amazon-apigateway-gateway-responses:
DEFAULT_4XX:
responseParameters:
gatewayresponse.header.Access-Control-Allow-Methods: "'OPTIONS,POST'"
gatewayresponse.header.Access-Control-Allow-Credentials: "'true'"
gatewayresponse.header.Access-Control-Allow-Origin: "'https://localhost:3000'"
gatewayresponse.header.Access-Control-Allow-Headers: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'"
DEFAULT_5XX:
responseParameters:
gatewayresponse.header.Access-Control-Allow-Methods: "'OPTIONS,POST'"
gatewayresponse.header.Access-Control-Allow-Credentials: "'true'"
gatewayresponse.header.Access-Control-Allow-Origin: "'https://localhost:3000'"
gatewayresponse.header.Access-Control-Allow-Headers: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'"