Description
Describe the bug
The response template value is invalid and results in a 500. The 500 response error is caused by an error thrown trying to transform the body because the velocity template language is invalid.
The issue is here: https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-apigateway/lib/integrations/stepfunctions.ts#L217
It should be this instead:
{
/**
* Match all '5XX' HTTP Errors
*/
selectionPattern: '5\\d{2}',
statusCode: '500',
responseTemplates: {
'application/json': `{
"error": "$input.path('$.error')"
}`,
},
},
Regression Issue
- Select this option if this issue appears to be a regression.
Last Known Working CDK Library Version
No response
Expected Behavior
Transform the body of the 500 integration response without erroring on the transformation.
Current Behavior
API Gateway throws an error on the transformation of the response because the VTL syntax is wrong.
Reproduction Steps
Deploy this construct and trigger a 500 response from the integration sdk request. Or use this bad VTL template in a 200 you'll see API Gateway error trying to transform the payload.
Possible Solution
The 400 template is correct, so re-use it but with the error value.
{
/**
* Match all '5XX' HTTP Errors
*/
selectionPattern: '5\\d{2}',
statusCode: '500',
responseTemplates: {
'application/json': `{
"error": "$input.path('$.error')"
}`,
},
},
Additional Information/Context
The current implementation is not valid JSON, it's just a string but it's expecting a JSON response.
AWS CDK Library version (aws-cdk-lib)
2.202.0
AWS CDK CLI version
4.0.0
Node.js Version
20.18.1
OS
osx
Language
TypeScript
Language Version
No response
Other information
No response