Skip to content

fix: allow ARC4 struct from_bytes with undersized backing bytes - #72

Open
mitre88 wants to merge 1 commit into
algorandfoundation:mainfrom
mitre88:mitre88/fix/struct-from-bytes-short-input
Open

fix: allow ARC4 struct from_bytes with undersized backing bytes#72
mitre88 wants to merge 1 commit into
algorandfoundation:mainfrom
mitre88:mitre88/fix/struct-from-bytes-short-input

Conversation

@mitre88

@mitre88 mitre88 commented Aug 22, 2026

Copy link
Copy Markdown

Summary

AVM construction of an ARC-4 struct from a short byte string does not fail immediately. It only errors when an operation reads past the backing bytes.

Struct.from_bytes(b\"\\x00\\x00\") on a type with a large static array used to raise input string is not long enough to be decoded immediately. It now stores the bytes, lets in-range fields (e.g. length) decode, and errors on out-of-range access (arr[0]).

Test plan

  • pytest tests/arc4/test_struct.py — 15 passed (includes new short-input case)
  • pytest tests/arc4/test_{struct,uintn,bool,string}.py

Fixes #45

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.

Constructing struct from minimum possible bytes value

1 participant