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

I am not able to overrdide 400 mapping template Integration Response #577

Open
piotrwalczak1 opened this issue Aug 7, 2023 · 0 comments

Comments

@piotrwalczak1
Copy link

piotrwalczak1 commented Aug 7, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant