-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
feat: add UnescapeMappingTemplate
to state machine Api
event
#2495
Conversation
Unescape
Unescape
to AWS::Serverless::StateMachine
Api
event
Unescape
to AWS::Serverless::StateMachine
Api
eventUnescape
to state machine Api
event
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #2495 +/- ##
===========================================
+ Coverage 93.58% 94.51% +0.93%
===========================================
Files 90 97 +7
Lines 6124 7311 +1187
Branches 1260 1526 +266
===========================================
+ Hits 5731 6910 +1179
- Misses 183 193 +10
+ Partials 210 208 -2 ☔ View full report in Codecov by Sentry. |
Unescape
to state machine Api
eventUnescapeMappingTemplate
to state machine Api
event
@@ -356,12 +357,18 @@ def _add_swagger_integration(self, api, resource, role, intrinsics_resolver): | |||
if CONDITION in resource.resource_attributes: | |||
condition = resource.resource_attributes[CONDITION] | |||
|
|||
request_template = ( | |||
self._generate_request_template_unescaped(resource) | |||
if self.UnescapeMappingTemplate |
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.
Probably a very rare use case - If this is a Fn::If
, the new behavior will be used regardless (as SAM-T can't/doesn't resolve Fn::If
). Is that wanted?
We had a similar discussion for PassthroughCondition
under DeploymentPreference
in #1578
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.
Doesn't
"UnescapeMappingTemplate": PropertyType(False, is_type(bool)),
already guarantee it's a bool
?
Edit: for posterity, no. We've deprecated PropertyType
since it's a footgun and we don't need to resolve intrinsics anymore.
api_endpoint = stack_output.get("ApiEndpoint") | ||
|
||
input_json = {"f'oo": {"hello": "'wor'l'd'''"}} | ||
response = requests.post(api_endpoint, json=input_json) |
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.
Can we add something similar to this so we will log the request too?
This will help us investigate in case of flaky test runs
Issue #, if available
#1895
Description of changes
Adds
UnescapeMappingTemplate
boolean to state machineApi
event, which unescapes singles quotes in state machine input escaped byescapeJavaScript
(which isn't valid JSON).The final mapping template isn't JSON by design, so can't use
json.dumps()
. For example:Originally done in #2253, but using an opt-in property instead to avoid large-scale redeployments.
Description of how you validated changes
Checklist
make pr
passesExamples?
Please reach out in the comments, if you want to add an example. Examples will be
added to
sam init
through https://github.com/awslabs/aws-sam-cli-app-templates/By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.