-
Notifications
You must be signed in to change notification settings - Fork 35
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
Fix bug with unicode handling in proto map keys #416
base: dev
Are you sure you want to change the base?
Conversation
In a map where the key is a string, containing unicode characters, yab may fail to properly decode the protobuf message. ``` // User Tags, key is tag name while value is the actual tag map<string, common.CustomerTag> tags = 11 ``` This is because the JSON string written by jump/protoreflect's MarshalJSONPB method doesn't correctly escape unicode characters. Inspecting the intermediate JSON we see invalid JSON: ``` "AU_P\342\200\231NutAsianKitchen_2024feb05-T": { ... } ``` This issue was fixed in jhump/protoreflect#481 in v1.10.2, however we upgrade the dependency to 1.15.6, the last before a breaking change to protobuf and a requirement to use go1.19. We can address this in a future PR. Tested: Before ``` $ yab .... | jq keys Failed while parsing response: invalid character '3' in string escape code Process 97171 has exited with status 1 ``` After ``` $ yab .... | jq keys [ "body", "headers" ] ``` `
In grpc/grpc-go#5197, there was a major change to server reflection, specifically: "If a [DescriptorResolver] is not present, protoregistry.GlobalFiles will be used. " It so happens that in simple.pb in the testdata there *is* a service called Foo and Bar and this is why these tests are now surprisingly passing instead of failing with unknown method errors. We work around this by creating method names that are unlikely to exist.
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.
Let's wait for the internal repository to remove version clamp on protoreflect, otherwise LGTM. Thanks!
Hey, what's the latest on this, I can't see Uber's internal repository removing the version clamp, and yab is a tool we publish OSS, so I forget why we are constrained by Uber's internal issues. |
We won't be able to apply any following fix internally. So let's make it in a right order: prepare internals first, then yab. |
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.
(I'll leave a "Request changes", though it's just a sign that we're currently blocked with this PR.)
In a map where the key is a string, containing unicode characters, yab may fail to properly decode the protobuf message.
This is because the JSON string written by jump/protoreflect's MarshalJSONPB method doesn't correctly escape unicode characters.
Inspecting the intermediate JSON we see invalid JSON:
This issue was fixed in jhump/protoreflect#481 in v1.10.2, however we upgrade the dependency to 1.15.6, the latest usable before a breaking change to protobuf and a requirement to use go1.19.
Before
After