Skip to content

Conversation

@jannotti
Copy link
Contributor

@jannotti jannotti commented Sep 5, 2025

Summary

With this change, when msgpacktool is 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 when msgpacktool encodes such a JSON blob, it will know to base64 decode the members of that slice.

Surprisingly, msgpacktool was 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

@jannotti jannotti changed the title allow arrays to be marked ":b64" cmds: allow arrays to be marked ":b64" Sep 5, 2025
@jannotti jannotti self-assigned this Sep 5, 2025
@jannotti jannotti requested review from algorandskiy and cce September 5, 2025 14:21
@cce
Copy link
Contributor

cce commented Sep 5, 2025

It looks like some tests in the transcode package (TestIdempotence, TestIdempotenceMultiobject) are broken from this change

algorandskiy
algorandskiy previously approved these changes Sep 5, 2025
@cce cce requested a review from Copilot September 5, 2025 17:46
Copy link
Contributor

Copilot AI left a 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.

gmalouf
gmalouf previously approved these changes Sep 5, 2025
@gmalouf gmalouf dismissed stale reviews from algorandskiy and themself via 5b2dc2e September 5, 2025 17:58
Needed to ensure that an empty slice did not get turned into null.
@jannotti jannotti force-pushed the msgpacktool-array-blobs branch from 5b2dc2e to e4665f6 Compare September 5, 2025 18:15
Copy link
Contributor

@cce cce left a 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

@jannotti jannotti merged commit 101fa77 into algorand:master Sep 5, 2025
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants