Fix TinyGo JSONBody[T] type-name collision - #24
Merged
Conversation
TinyGo's generic-function monomorphization keys plugin.JSONBody[T]
instantiations by T's bare type name rather than its full declaration
site. This package declared 8 locally-scoped `type bodyT struct{...}`
types across integration.go, branches.go, and pull_requests.go -- same
name, different fields per handler. TinyGo collapsed them into one
shared field layout, so json.Unmarshal silently decoded most call
sites against the wrong struct: fields came out zeroed with no error,
indistinguishable from an empty request body.
Renamed every JSONBody[T] body type to a name unique within the
package (e.g. setTokenBody, linkRepositoryBody). Verified by building
with the exact TinyGo version CI uses and driving the real binary
through the actual host runtime -- previously-broken routes now
correctly see their decoded fields.
Fixes Paca-AI/paca#445.
This was referenced Aug 30, 2026
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
Fixes Paca-AI/paca#445 ("Plugin POST requests reach the WASM guest with an empty body").
The root cause is not in the
pacahost runtime (verified exhaustively — the WASM memory protocol and JSON envelope marshaling are correct). It's a TinyGo compiler behavior:plugin.JSONBody[T]is generic, and TinyGo's generic-function monomorphization appears to key instantiations byT's bare type name rather than its full declaration site.This package declared 8 locally-scoped
type bodyT struct{...}types acrossintegration.go,branches.go, andpull_requests.go— same name, different fields per handler (e.g.setToken's{Token string}vslinkRepository's{Owner, RepoName string}). TinyGo collapsed these into one shared field layout, sojson.Unmarshalsilently decoded most call sites against the wrong struct: fields came out zeroed with no error, indistinguishable from an empty request body.Fix
Renamed every
JSONBody[T]body type to a name unique within the package (setTokenBody,linkRepositoryBody,createBranchBody, etc.) — 8 renames across 3 files, no behavior changes otherwise.Verification
tinygo build -target=wasip1 -buildmode=c-shared, v0.41.1)services/api/internal/platform/plugin.Runtime), confirmingreq.Bodyarrives intact and previously-broken routes now correctly decode their fieldsgo test ./...andgo vet ./...passRelated
This same pattern (reused local type name across
JSONBody[T]call sites, broken by TinyGo) was found and fixed across all first-party plugins that switched to TinyGo builds: paca-plugin-bdd, paca-plugin-checklist, paca-plugin-dashboard, paca-plugin-example, paca-plugin-time-logging, paca-plugin-webhook.plugin-sdk-goalso got a non-genericJSONBodyIntohelper added as a documented escape hatch going forward.🤖 Generated with Claude Code