-
Notifications
You must be signed in to change notification settings - Fork 459
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
json: ser/de bytes as base64 strings not an array of bytes #2471
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2471 +/- ##
=====================================
Coverage 77.1% 77.1%
=====================================
Files 124 124
Lines 23021 23021
=====================================
Hits 17771 17771
Misses 5250 5250 ☔ View full report in Codecov by Sentry. |
I'm not familiar with the codebase so I took a guess as to where to apply the fix. I tried to add an integration test but I could not get a failure case to fail a test so I'm not sure if that's even in the right place either. Some pointers would be appreciated. |
@@ -182,6 +189,17 @@ pub(crate) mod serializers { | |||
let s: String = Deserialize::deserialize(deserializer)?; | |||
s.parse::<i64>().map_err(de::Error::custom) | |||
} | |||
|
|||
pub fn serialize_vec_u8_as_base64_string<S: Serializer>(v: &Vec<u8>, s: S) -> Result<S::Ok, S::Error> { |
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.
Are we planning to use these methods in the future, given that they are currently unused?
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.
Yes but I'm not sure where or how. I'm having some trouble grokking the codebase because of all of the codegen.
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 don't see bytes <-> base64 conversion required outside of AnyValue::Value
. The only other candidates could have been traceid
, spanid
byte arrays but they are encoded as hex-str as per the specs. So it should be safe to remove these methods for now, and bring back later if required.
"key": "data", | ||
"value": { | ||
"bytesValue": "gICA" | ||
} |
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.
To make it complete, can we also add this entry in the json samples for logs and metrics?
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.
Sure yes!
I believe this is how the proto <-> json spec defines that binary data should be handled: https://protobuf.dev/programming-guides/json/
I confirmed by exporting data from Python: