Draft
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes errors that occurred when trying to encode non-ASCII data as String in MessagePack deserialization. The solution changes several field types from String to Vec<u8> and implements custom serde handling for MessagePack strings that may contain non-UTF-8 data.
Changes:
- Added custom serde module
msgpack_string_bytesto handle MessagePack strings as raw bytes - Changed
BlockStateDeltafrom a type alias to a struct with custom serialization to supportVec<u8>keys - Updated field types in
BlockEvalDeltaandBlockAppEvalDeltafromString/Vec<String>toVec<u8>/Vec<Vec<u8>>
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/algod_client/src/msgpack_string_bytes.rs | New serde module for deserializing msgpack strings as raw bytes |
| crates/algod_client/src/models/block_state_delta.rs | Changed from type alias to struct with custom serialization for byte-keyed HashMap |
| crates/algod_client/src/models/block_eval_delta.rs | Changed bytes field from Option<String> to Option<Vec<u8>> |
| crates/algod_client/src/models/block_app_eval_delta.rs | Changed logs field from Option<Vec<String>> to Option<Vec<Vec<u8>>> |
| crates/algod_client/src/lib.rs | Added msgpack_string_bytes module export |
| api/oas_generator/rust_oas_generator/templates/models/block/block_state_delta.rs.j2 | Template file mirroring changes to block_state_delta.rs |
| api/oas_generator/rust_oas_generator/templates/models/block/block_eval_delta.rs.j2 | Template file mirroring changes to block_eval_delta.rs |
| api/oas_generator/rust_oas_generator/templates/models/block/block_application_eval_delta.rs.j2 | Deleted file (appears to be unused) |
| api/oas_generator/rust_oas_generator/templates/models/block/block_app_eval_delta.rs.j2 | Template file mirroring changes to block_app_eval_delta.rs |
| api/oas_generator/rust_oas_generator/templates/base/msgpack_string_bytes.rs.j2 | Template file for msgpack_string_bytes module |
| api/oas_generator/rust_oas_generator/templates/base/lib.rs.j2 | Template file mirroring changes to lib.rs |
| api/oas_generator/rust_oas_generator/generator/template_engine.py | Added generation logic for msgpack_string_bytes.rs |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
api/oas_generator/rust_oas_generator/templates/models/block/block_state_delta.rs.j2
Outdated
Show resolved
Hide resolved
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.
This fixes errors that were thrown when trying to encode non-ascii data as String
It should be noted that this PR does introduce unsafe code because we need to encode the data as string, but the serde serailizer can only encode a string from a
&str, thus we must convert aVec<u8>to a&strto preserve all the data.