From f3502a4488eea171c149aef02e3c1c78334f36c1 Mon Sep 17 00:00:00 2001 From: Daniel Prevoznik Date: Wed, 17 Dec 2025 09:26:26 -0500 Subject: [PATCH] fix: preserve URL query strings in invoke output Go's json.MarshalIndent escapes '&' (and <, >) as unicode sequences like \u0026. This breaks copy/paste of URLs returned in invocation output (e.g. browser replay URLs). Use a JSON encoder with SetEscapeHTML(false) when pretty-printing invocation output. --- cmd/invoke.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cmd/invoke.go b/cmd/invoke.go index 2ac29b0..913a643 100644 --- a/cmd/invoke.go +++ b/cmd/invoke.go @@ -1,6 +1,7 @@ package cmd import ( + "bytes" "context" "encoding/json" "fmt" @@ -194,8 +195,15 @@ func handleSdkError(err error) error { func printResult(success bool, output string) { var prettyJSON map[string]interface{} if err := json.Unmarshal([]byte(output), &prettyJSON); err == nil { - bs, _ := json.MarshalIndent(prettyJSON, "", " ") - output = string(bs) + // Use a custom encoder to prevent escaping &, <, > as \u0026, \u003c, \u003e + // which breaks copy/paste of URLs in the invoke output. + var buf bytes.Buffer + encoder := json.NewEncoder(&buf) + encoder.SetEscapeHTML(false) + encoder.SetIndent("", " ") + if err := encoder.Encode(prettyJSON); err == nil { + output = strings.TrimSuffix(buf.String(), "\n") + } } // use pterm.Success if succeeded, pterm.Error if failed if success {