feat: follow graphQL spec when encoding UTF-8 unicodes (Go SDK) #5169
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
In order to properly escape strings, especially binary data on Go SDK, we now follow graphQL's spec around strings escape.
Limitations
This fix only fixes the escape of UTF-8 unicodes, as the JSON Unmarshall of Go correctly escapes these unicodes, when unmarshalling as a String.
For the mount of binary files, we will need to follow an alternative. Discussion happening here: #5069
Thus, we expect to have, as inputs of type string, UTF-8 unicodes. Follow-ups will be implemented for other SDKs, if necessary.
Repro
This PR enables the mount / copy of exact bytes sequences inside container, for UTF-8 unicodes, for Go SDK
main.go
foo
Please create a file named
foo
, with the content of the unicode_test added in this PR. Cannot properly copy-paste it here and on gist.github.comProving that foo is
UTF-8
script.py
Output:
python3 script.py The file 'foo' is UTF-8 encoded: True
Current issue
Given this UTF-8 only string of unicodes, our current Go SDK codegen breaks:
With this PR, we properly escape it:
As you can see, the data is preserved: the md5 hash is the same in the container and locally
Only Go SDK is concerned
@helderco, Node and Python SDK are properly managing UTF-8 unicodes. So no need to apply the changes to these SDKs:
Repro
The code is not perfect (not the aim), but it works:
Node SDK
Output on console:
Python SDK
output: