-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
APIGW: fix rendering of $input.body when empty #12413
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
Conversation
67acd30
to
8c97dfb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! A clean one line fix for 300 lines of testing! 🚀
Thanks for deep dive and addressing this issue in VTL, it looks like we will never be out of surprise from it! 🤣
for rest_api_id, _client_region_name in rest_apis: | ||
apigateway_client = aws_client_factory( | ||
region_name=_client_region_name, | ||
config=retry_boto_config, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch!
"recorded-date": "19-03-2025, 17:03:40", | ||
"recorded-content": { | ||
"response-raw-body": { | ||
"empty-body": "b'{}'", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm! interesting! nice find
"response-body-attr-access": { | ||
"empty-body": "b'{}'", | ||
"json-body": "b'{}'", | ||
"str-body": "b'{}'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was trying to expect what would come out of it... not what I thought! 🤣
Motivation
We broke an upstream integration test following #12322, because API Gateway would forward an empty body to the SQS integration, and SQS disallows that.
This is because API Gateway will replace an empty body with
{}
when using$input.body
in a VTL template.I've added a few tests validating the assumption, and @dfangl added the SQS regression test to make sure we don't break upstream anymore. He also added some changes in the retry mechanism for deleting REST APIs, and I've updated it to use the Boto config in both creation and deletion of REST APIs.
note: I've also tried with a request template set with
text/html
and the empty body is still{}
so it's not dependent on the content-type.Changes
{}
string if the body is empty for$input.body
(so that it can be passed to function like$util.urlEncode
)