yarpc / yab

Call and benchmark YARPC services from the command line.
MIT License
86 stars 35 forks source link

Fix bug with unicode handling in proto map keys #416

Open jquirke opened 4 months ago

jquirke commented 4 months ago

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 https://github.com/jhump/protoreflect/pull/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

$ 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"
]