serverless-step-functions
serverless-step-functions copied to clipboard
I am not able to overrdide 400 mapping template Integration Response
This is a (Bug Report / Feature Proposal)
I am using a DescribeExecution aws step function integration for api gateway. I cannot update custom mapping template for 400 status if the body of the request contains non existing arn.
I am sending: POST /endpoint/path with body {"executionArn": "abcdef}. When bad request is returned I am getting:
{
"__type": "com.amazonaws.swf.service.v2.model#InvalidArn",
"message": "Invalid Arn: 'Invalid ARN prefix: abcdef'"
}
I would like to get:
{
type: BadRequest
status: "Incorrect body parameters"
}
Description
I am not able to modify mapping template for 400 integration response. According to documentation there is no way to update the template separately for 200 & 400 responses.
My code:
- http:
path: endpoint/path
method: POST
action: DescribeExecution
response:
template:
application/json: |-
#set($inputRoot = $input.path('$'))
{
"status": $inputRoot.status
}
This updates the 200 integration response. But I want to modify the template for 400 as well. I tried the standard statusCodes for serveless way but it does not work.
I tried according to serverless docs:
- http:
path: endpoint/path
method: POST
action: DescribeExecution
response:
template:
application/json: |-
#set($inputRoot = $input.path('$'))
{
"status": $inputRoot.status
}
statusCodes:
200:
pattern: ""
400:
pattern: '.*"statusCode":400,.*"
template:
application/json: |-
{
type: BadRequest
status: "Incorrect body parameters"
}
I also tried to override the default gateway status codes for this, but it does not work (I overrided 4xx, 429, 400 for default gateway responses). I have default gateway responses for application/json defined as:
{
type: BadRequest
status: "Incorrect body parameters"
}
It still returns. Mapping template for 400 is not visibile in the aws console.
{
"__type": "com.amazonaws.swf.service.v2.model#InvalidArn",
"message": "Invalid Arn: 'Invalid ARN prefix: abcdef'"
}
If it occurrs that there is a way to do that, please UPDATE documentation, because it is a common usecase.