cmds: allow arrays to be marked ":b64"#6436
Merged
jannotti merged 2 commits intoalgorand:masterfrom Sep 5, 2025
Merged
Conversation
Contributor
|
It looks like some tests in the transcode package ( |
algorandskiy
previously approved these changes
Sep 5, 2025
Contributor
There was a problem hiding this comment.
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.
gmalouf
reviewed
Sep 5, 2025
gmalouf
previously approved these changes
Sep 5, 2025
gmalouf
approved these changes
Sep 5, 2025
Needed to ensure that an empty slice did not get turned into null.
5b2dc2e to
e4665f6
Compare
cce
approved these changes
Sep 5, 2025
Contributor
cce
left a comment
There was a problem hiding this comment.
LGTM — only affects msgpacktool and goal ledger block which shows a JSON block
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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