-
Notifications
You must be signed in to change notification settings - Fork 519
cmds: allow arrays to be marked ":b64" #6436
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
Conversation
|
It looks like some tests in the transcode package ( |
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.
Pull Request Overview
Extends msgpacktool to handle arrays of byte slices by automatically appending ":b64" suffix to JSON keys when encoding, enabling proper round-trip conversion between msgpack and JSON formats for byte array data.
- Add support for detecting and marking slices of bytes with ":b64" suffix during JSON encoding
- Implement corresponding decoding logic to convert base64-encoded string arrays back to byte slices
- Update test generation to create more uniform array types for better coverage
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| protocol/transcode/core.go | Core transcoding logic with new helper functions and enhanced encoding/decoding for byte slice arrays |
| protocol/transcode/core_test.go | Test improvements with better error reporting and enhanced random object generation |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Needed to ensure that an empty slice did not get turned into null.
5b2dc2e to
e4665f6
Compare
cce
left a comment
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.
LGTM — only affects msgpacktool and goal ledger block which shows a JSON block
Summary
With this change, when
msgpacktoolis decoding to JSON, and finds a slice that consists entirely of[]bytes as the value of a string key, it will append ":b64" to the keyname, so that whenmsgpacktoolencodes such a JSON blob, it will know to base64 decode the members of that slice.Surprisingly,
msgpacktoolwas already b64 encoding the slice members --- this change just makes it so that it converts them back to bytes later.This does not change any REST APIs, but the output of a goal command that prints a block uses this change (for the better, I think).
Test Plan