-
Notifications
You must be signed in to change notification settings - Fork 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(events): support embedded string variables #13487
Conversation
4f7d161
to
69e5eff
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.
Thanks for the work, but please use the PR body to describe the problem, the solution you came up with and any potential trade offs that had to be made. This is both useful for me to judge the contribution right now, as well as will come in useful later if we ever need to do software archeology.
I see changes in the PR that I didn't expect and don't seem safe. I don't know what to make of them, or why you thought these changes won't cause any problems.
fixes #1234
hardly gives me the context I need to properly evaluate the impact of this change.
3a5dbc1
to
16e3870
Compare
16e3870
to
e5d7b70
Compare
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Event Bridge transformers have been updated to support embedded variable replacement within strings within objects. ``` { data: "some string <myValue>" } ``` Previously input transformers only supported string when they were the only value of an object, or just static strings. ``` // Before Event Bridges's change { data: <myValue>, // OK data2: "some string", // OK data3: "some string <myValue>" // NOT OK } ``` The CDK solution was to assume that developers knew this restriction, wrap the string variable in special characters, and replace the double quotes plus special character set with nothing after token replacement. This caused issues like aws#9191. Where string tokens (`EventField`) within a string would give a cryptic error during Cfn deployment due the resulting invalid object string generated (missing a closing double quote and leaving the special characters behind). ### Solution: Removed the special character sequence addition and stripping and instead only replace any instances of `"<myValue>"` that are added. * Iterate over the known input transform keys to reduce possible unexpected impact and give developers a backdoor to change their keys in the worst case. * Edge Case: `"<myValue>"` can appear with escaped quote sequences `"something \"quoted\"<myValue>"`. This is a valid string variable replacement case. Used a lookback regex (`(?<!\\\\)\"\<${key}\>\"`) to avoid the prefix escaped quote when replacing transform input keys with quote-less keys. ### Tradeoffs Removed the addition of special characters to find the keys in the final json string. Instead search for the specific pattern of transform input keys that should exist within the output and handle the edge case describe above. This SHOULD cover all edge cases as it is not valid to have a trailing quote without an escape (`"<myValue>"" //not valid`) and it is not valid to have a prefix quote that is not escaped (`""<myValue>" // not valid`). This was done to reduce the small change of overlapping with a developer's content, to be more targeted, and because the above should prove that the edge case is covered. https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_InputTransformer.html fixes aws#9191 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Event Bridge transformers have been updated to support embedded variable replacement within strings within objects.
Previously input transformers only supported string when they were the only value of an object, or just static strings.
The CDK solution was to assume that developers knew this restriction, wrap the string variable in special characters, and replace the double quotes plus special character set with nothing after token replacement.
This caused issues like #9191. Where string tokens (
EventField
) within a string would give a cryptic error during Cfn deployment due the resulting invalid object string generated (missing a closing double quote and leaving the special characters behind).Solution:
Removed the special character sequence addition and stripping and instead only replace any instances of
"<myValue>"
that are added."<myValue>"
can appear with escaped quote sequences"something \"quoted\"<myValue>"
. This is a valid string variable replacement case. Used a lookback regex ((?<!\\\\)\"\<${key}\>\"
) to avoid the prefix escaped quote when replacing transform input keys with quote-less keys.Tradeoffs
Removed the addition of special characters to find the keys in the final json string. Instead search for the specific pattern of transform input keys that should exist within the output and handle the edge case describe above.
This SHOULD cover all edge cases as it is not valid to have a trailing quote without an escape (
"<myValue>"" //not valid
) and it is not valid to have a prefix quote that is not escaped (""<myValue>" // not valid
).This was done to reduce the small change of overlapping with a developer's content, to be more targeted, and because the above should prove that the edge case is covered.
https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_InputTransformer.html
fixes #9191
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license