Skip to content

fix(foundation): Fix Zod serde for Buffer32#23240

Merged
AztecBot merged 1 commit into
nextfrom
arv/fix_buffer32_serde
May 13, 2026
Merged

fix(foundation): Fix Zod serde for Buffer32#23240
AztecBot merged 1 commit into
nextfrom
arv/fix_buffer32_serde

Conversation

@sirasistant
Copy link
Copy Markdown
Contributor

@sirasistant sirasistant commented May 13, 2026

Summary

  • Buffer32.fromString and fromBuffer28 referenced this.SIZE, which broke when the static method was called with a different this (e.g. passed unbound to z.transform in schemas.Buffer32, where this.SIZE became undefined and the length check threw "Expected string to be NaN characters long, but was 64").
  • Replace remaining this.SIZE uses with Buffer32.SIZE so the static methods don't depend on call-site binding. The rest of the class already used Buffer32.SIZE — this just removes the mix.
  • Add a regression test that round-trips a random Buffer32 through schemas.Buffer32.

@sirasistant sirasistant requested a review from spalladino May 13, 2026 11:13
Copy link
Copy Markdown
Contributor

@spalladino spalladino left a comment

Choose a reason for hiding this comment

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

Looks good, but I'd argue the proper fix is replacing all this.SIZE with Buffer32.SIZE in Buffer32's static methods (today it's a mix).

@sirasistant
Copy link
Copy Markdown
Contributor Author

It's true that using this in a class-static context smells weird. Will switch!

## Summary

- `Buffer32.fromString` and `fromBuffer28` referenced `this.SIZE`, which broke when the static method was called with a different `this` (e.g. passed unbound to `z.transform` in `schemas.Buffer32`, where `this.SIZE` became `undefined` and the length check threw `"Expected string to be NaN characters long, but was 64"`).
- Replace remaining `this.SIZE` uses with `Buffer32.SIZE` so the static methods don't depend on call-site binding. The rest of the class already used `Buffer32.SIZE` — this just removes the mix.
- Add a regression test that round-trips a random `Buffer32` through `schemas.Buffer32`.
@AztecBot AztecBot force-pushed the arv/fix_buffer32_serde branch from bdd13cb to 4625734 Compare May 13, 2026 14:00
@AztecBot AztecBot enabled auto-merge May 13, 2026 14:00
@AztecBot AztecBot added this pull request to the merge queue May 13, 2026
Merged via the queue into next with commit fe021af May 13, 2026
21 checks passed
@AztecBot AztecBot deleted the arv/fix_buffer32_serde branch May 13, 2026 14:51
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.

3 participants