Fix TinyGo JSONBody[T] type-name collision - #16
Merged
Conversation
TinyGo's generic-function monomorphization keys plugin.JSONBody[T]
instantiations by T's bare type name rather than its full declaration
site. createChecklist/updateChecklist and createItem/updateItem each
declared their own `type body struct{...}` -- same name reused four
times in the package, with three distinct field shapes among them.
TinyGo could collapse these into one shared field layout, so
json.Unmarshal would silently decode some call sites against the
wrong struct.
Renamed all four to createChecklistBody / updateChecklistBody /
createItemBody / updateItemBody so every JSONBody[T] argument is
unique within the package -- including the two that happened to share
an identical shape already, since that safety was coincidental and
fragile to a future edit.
Part of a coordinated fix across all first-party plugins; see
Paca-AI/paca#445 and Paca-AI/paca-plugin-github#24 for the full
root-cause writeup and verification.
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.
Summary
Part of the fix for Paca-AI/paca#445 — see Paca-AI/paca-plugin-github#24 for the full root-cause writeup (TinyGo generic-function monomorphization silently collapsing same-named-but-different-shape local types passed to
plugin.JSONBody[T]).This package had four locally-scoped
type body struct{...}declarations sharing the same name acrosschecklists.go(createChecklist,updateChecklist) anditems.go(createItem,updateItem), with three distinct field shapes among them. Under TinyGo this risksjson.Unmarshalsilently decoding a request against the wrong struct's field layout.Fix
Renamed all four to
createChecklistBody/updateChecklistBody/createItemBody/updateItemBody— including the two that happened to share an identical shape already, since that safety was coincidental and fragile to a future edit.Verification
go test ./...andgo vet ./...pass.🤖 Generated with Claude Code