From 3a36ca5e71c950aac7a643d4b55feeef1fae480c Mon Sep 17 00:00:00 2001 From: Holger Waschke Date: Wed, 18 Mar 2026 10:16:58 +0100 Subject: [PATCH 1/2] feat(deepcopywithtemplate): improvments to keep quoted scalar as string Signed-off-by: Holger Waschke --- template/template.go | 8 +++++++- template/template_test.go | 8 ++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/template/template.go b/template/template.go index fbb28541c1..74063ee5f7 100644 --- a/template/template.go +++ b/template/template.go @@ -463,10 +463,16 @@ func DeepCopyWithTemplate(value any, tmplTextFunc TemplateFunc) (any, error) { if ok == nil { var inlineType any err := yaml.Unmarshal([]byte(parsed), &inlineType) - if err != nil || (inlineType != nil && reflect.TypeOf(inlineType).Kind() == reflect.String) { + if err != nil { // ignore error, thus the string is not an interface return parsed, ok } + if inlineString, isString := inlineType.(string); isString { + return inlineString, ok + } + if strings.TrimSpace(parsed) == "" { + return parsed, ok + } return DeepCopyWithTemplate(inlineType, tmplTextFunc) } return parsed, ok diff --git a/template/template_test.go b/template/template_test.go index 9d481ced2c..599a6fa4c6 100644 --- a/template/template_test.go +++ b/template/template_test.go @@ -693,6 +693,14 @@ func TestDeepCopyWithTemplate(t *testing.T) { fn: withSuffix, want: "hello-templated", }, + { + title: "quoted numeric string stays string", + input: "hello", + fn: TemplateFunc(func(string) (string, error) { + return "\"123\"", nil + }), + want: "123", + }, { title: "string parsed as YAML map", input: "foo: bar", From 0da52319908d539c582f86266b882cdff19f22ba Mon Sep 17 00:00:00 2001 From: Holger Waschke Date: Fri, 20 Mar 2026 10:25:27 +0100 Subject: [PATCH 2/2] chore(template_test.go): add additional unit test to test deepcopywithtemplate Signed-off-by: Holger Waschke --- template/template_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/template/template_test.go b/template/template_test.go index 599a6fa4c6..fb93a9335c 100644 --- a/template/template_test.go +++ b/template/template_test.go @@ -701,6 +701,25 @@ func TestDeepCopyWithTemplate(t *testing.T) { }), want: "123", }, + { + title: "quoted numeric string stays string in nested map", + input: map[string]any{ + "customfield_11209": map[string]any{ + "id": "TOKEN", + }, + }, + fn: TemplateFunc(func(s string) (string, error) { + if s == "TOKEN" { + return "\"15129\"", nil + } + return s, nil + }), + want: map[string]any{ + "customfield_11209": map[string]any{ + "id": "15129", + }, + }, + }, { title: "string parsed as YAML map", input: "foo: bar",