feat: add UnescapeMappingTemplate to state machine Api event#2495
feat: add UnescapeMappingTemplate to state machine Api event#2495hoffa wants to merge 7 commits into
UnescapeMappingTemplate to state machine Api event#2495Conversation
UnescapeUnescape 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
|
|
||
| request_template = ( | ||
| self._generate_request_template_unescaped(resource) | ||
| if self.UnescapeMappingTemplate |
There was a problem hiding this comment.
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.
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.
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
UnescapeMappingTemplateboolean to state machineApievent, 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:{"input": "$util.escapeJavaScript($input.json('$')).replaceAll("\\'","'")", "stateMachineArn": "arn:aws:states:us-east-1:792766875239:stateMachine:Post-n7ZKNljUJsZZ"}Originally done in #2253, but using an opt-in property instead to avoid large-scale redeployments.
Description of how you validated changes
Checklist
make prpassesExamples?
Please reach out in the comments, if you want to add an example. Examples will be
added to
sam initthrough 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.