Skip to content

Remove support for decoding positional encoding (structs as arrays) from code generator - #37

Merged
jannotti merged 1 commit into
masterfrom
remove-array-decode
Jul 10, 2026
Merged

Remove support for decoding positional encoding (structs as arrays) from code generator#37
jannotti merged 1 commit into
masterfrom
remove-array-decode

Conversation

@cce

@cce cce commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Remove unused code path for msgp positional encoding

@cce
cce requested review from algorandskiy, Copilot and jannotti July 10, 2026 12:34
@cce cce changed the title reject array-decoded msgp Remove support for decoding positional encoding (structs as arrays) from code generator Jul 10, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes the legacy fallback that allowed “map-structs” (normal msgp structs) to be decoded from array-encoded msgpack values (positional/Go-field-order decoding), making map-struct decoding strictly require a msgpack map. It adds targeted tests to ensure array-encoded inputs are rejected while explicit tuple structs continue to support array encoding.

Changes:

  • Removed the generator’s “struct-from-array” fallback path for map-encoded structs (now map-only).
  • Updated generated test fixtures (tests/required_gen.go) to reflect map-only decoding.
  • Added tests asserting that array-encoded inputs for map-structs are rejected, while //msgp:tuple structs still decode arrays.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.

File Description
tests/required_gen.go Regenerated unmarshaling code to remove array fallback and enforce map-only decoding for map-structs.
tests/array_decode_test.go Adds coverage ensuring array-encoded values are rejected for map-structs, and tuple structs still round-trip via arrays.
gen/unmarshal.go Removes the array-decoding fallback from the struct unmarshal generator and updates related comments.
Files not reviewed (1)
  • tests/required_gen.go: Generated file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread gen/unmarshal.go
// object, or encoded as a zero value) is a decode error. This runs after the
// struct body has been decoded, so it applies uniformly to the map,
// struct-from-array, and tuple decode paths.
// struct body has been decoded, so it applies uniformly to the map and tuple

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the "tuple" path?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can specify //msgp:tuple and have a struct encoded as a positional array. It doesn't look like we've ever used this feature though.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can/should we remove that as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel less concerned about it, as it is an explicit opt-in, and not automatic fallback behavior that is being generated whether you specified array/tuple encoding or not.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I could remove it

@jannotti jannotti left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The encoding path is already gone? So there's essentially no way any reasonably modern hunk of msgp contains anything that needs to be decoded this way?

I guess we need to confirm that no old blocks/bundles contain anything done this way?

@jannotti
jannotti merged commit c8c4985 into master Jul 10, 2026
3 checks passed
@cce
cce deleted the remove-array-decode branch July 10, 2026 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants