From 4b6329de7e00b9ead8aaf80005a2cb50a24fe30c Mon Sep 17 00:00:00 2001 From: samuraikillers Date: Sun, 15 Feb 2026 21:46:50 +0530 Subject: [PATCH] fix(postrenderer): correctly serialize manifests for WASM plugins WASM post-renderer plugins were receiving empty manifests because bytes.Buffer does not serialize its contents when encoded to JSON. This change updates the schema to use string and converts between string and bytes.Buffer at runtime boundaries so manifests are passed correctly to and from plugins. Signed-off-by: samuraikillers --- internal/plugin/runtime_subprocess.go | 4 ++-- internal/plugin/schema/postrenderer.go | 8 ++------ pkg/postrenderer/postrenderer.go | 6 +++--- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/internal/plugin/runtime_subprocess.go b/internal/plugin/runtime_subprocess.go index c836c1c6d..1d47ba745 100644 --- a/internal/plugin/runtime_subprocess.go +++ b/internal/plugin/runtime_subprocess.go @@ -255,7 +255,7 @@ func (r *SubprocessPluginRuntime) runPostrenderer(input *Input) (*Output, error) go func() { defer stdin.Close() - io.Copy(stdin, msg.Manifests) + io.Copy(stdin, bytes.NewBufferString(msg.Manifests)) }() postRendered := &bytes.Buffer{} @@ -272,7 +272,7 @@ func (r *SubprocessPluginRuntime) runPostrenderer(input *Input) (*Output, error) return &Output{ Message: schema.OutputMessagePostRendererV1{ - Manifests: postRendered, + Manifests: postRendered.String(), }, }, nil } diff --git a/internal/plugin/schema/postrenderer.go b/internal/plugin/schema/postrenderer.go index ef51a8a61..cda29b4b2 100644 --- a/internal/plugin/schema/postrenderer.go +++ b/internal/plugin/schema/postrenderer.go @@ -16,19 +16,15 @@ limitations under the License. package schema -import ( - "bytes" -) - // InputMessagePostRendererV1 implements Input.Message type InputMessagePostRendererV1 struct { - Manifests *bytes.Buffer `json:"manifests"` + Manifests string `json:"manifests"` // from CLI --post-renderer-args ExtraArgs []string `json:"extraArgs"` } type OutputMessagePostRendererV1 struct { - Manifests *bytes.Buffer `json:"manifests"` + Manifests string `json:"manifests"` } type ConfigPostRendererV1 struct{} diff --git a/pkg/postrenderer/postrenderer.go b/pkg/postrenderer/postrenderer.go index 55e6d3adf..e37ffb3f8 100644 --- a/pkg/postrenderer/postrenderer.go +++ b/pkg/postrenderer/postrenderer.go @@ -64,7 +64,7 @@ func (r *postRendererPlugin) Run(renderedManifests *bytes.Buffer) (*bytes.Buffer input := &plugin.Input{ Message: schema.InputMessagePostRendererV1{ ExtraArgs: r.args, - Manifests: renderedManifests, + Manifests: renderedManifests.String(), }, } output, err := r.plugin.Invoke(context.Background(), input) @@ -76,9 +76,9 @@ func (r *postRendererPlugin) Run(renderedManifests *bytes.Buffer) (*bytes.Buffer // If the binary returned almost nothing, it's likely that it didn't // successfully render anything - if len(bytes.TrimSpace(outputMessage.Manifests.Bytes())) == 0 { + if len(bytes.TrimSpace([]byte(outputMessage.Manifests))) == 0 { return nil, fmt.Errorf("post-renderer %q produced empty output", r.plugin.Metadata().Name) } - return outputMessage.Manifests, nil + return bytes.NewBufferString(outputMessage.Manifests), nil }