-
Notifications
You must be signed in to change notification settings - Fork 420
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
Resolving newline in TriggerBinding param #953
Conversation
Closes tektoncd#942 This PR resolves the bug by replacing all instances of the \n character in triggerbinding params with \n, thus encoding into JSON as the bytes 92 110 rather than 10 or 13 10 depending on the system. This works in any instance where the parameter is substituted as the JSON encoding will resolve the parameter value after the byte array for the constructed rawMessage is assembled. Therefore, anywhere that the newline character is in one of these parameters, it will not encode appropriately in JSON. This was determined based on the existing tests that use \n in the label fields. Since the JSON encoder already operate successfully with those fields, we can look at the resultant byte array when those tests are run and determine the appropriate input that should be passed to the replace function in resource.go
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Hi @jmcshane. Thanks for your PR. I'm waiting for a tektoncd member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
I couldn't find anywhere to document this as it appears that this is the desired behavior. One thing I did find is that if you are trying to do a multi-line JSON document, you do need to use the old-escape annotation. I put that in the new sink_test.go test to demonstrate the difference between a standard string with multiple lines and a JSON string |
Closing in favor of a more general approach for encoding resources |
So, I was taking another look at this issue and I think we might want to merge this. I tried out a few triggers with newline chars as well as some quotes. I found that #823 fixes the issues with escaping quotes -- I could successfully use a trigger with a param that contains I tried a few triggers with other escaped chars ( e.g. |
Closes #942
This PR resolves the bug by replacing all instances of the \n character
in triggerbinding params with \n, thus encoding into JSON as the bytes
92 110 rather than 10 or 13 10 depending on the system. This works in any
instance where the parameter is substituted as the JSON encoding will resolve
the parameter value after the byte array for the constructed rawMessage is
assembled. Therefore, anywhere that the newline character is in one of these
parameters, it will not encode appropriately in JSON.
This was determined based on the existing tests that use \n in the label fields.
Since the JSON encoder already operate successfully with those fields, we can look
at the resultant byte array when those tests are run and determine the appropriate
input that should be passed to the replace function in resource.go
Changes
Submitter Checklist
These are the criteria that every PR should meet, please check them off as you
review them:
See the contribution guide for more details.
Release Notes