Skip to content

Fix TinyGo JSONBody[T] type-name collision - #16

Merged
pikann merged 2 commits into
masterfrom
fix/jsonbody-tinygo-collision
Aug 30, 2026
Merged

Fix TinyGo JSONBody[T] type-name collision#16
pikann merged 2 commits into
masterfrom
fix/jsonbody-tinygo-collision

Conversation

@pikann

@pikann pikann commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

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]).

createScenario and updateScenario in backend/scenarios.go each declared their own locally-scoped type body struct{...} with the same name but different field types (string vs *string, for create vs partial-update semantics). Under TinyGo this is exactly the collision pattern: json.Unmarshal could silently decode a request against the wrong struct's field layout — worse here than a simple zeroing, since string and *string have different in-memory sizes.

Fix

Renamed both to createScenarioBody / updateScenarioBody.

Verification

go test ./... and go vet ./... pass.

🤖 Generated with Claude Code

pikann added 2 commits August 30, 2026 16:40
TinyGo's generic-function monomorphization keys plugin.JSONBody[T]
instantiations by T's bare type name rather than its full declaration
site. createScenario and updateScenario each declared their own
`type body struct{...}` with the same name but different fields
(string vs *string) -- TinyGo collapsed them into one shared field
layout, so json.Unmarshal could decode against the wrong struct
(differing field sizes here, not just differing field counts).

Renamed both to createScenarioBody / updateScenarioBody.

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.
@pikann
pikann merged commit 65d61cd into master Aug 30, 2026
3 checks passed
@pikann
pikann deleted the fix/jsonbody-tinygo-collision branch August 30, 2026 16: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.

1 participant