diff --git a/clients/go/coreutils/literals.go b/clients/go/coreutils/literals.go index c05061854d..2a6b10bb0a 100644 --- a/clients/go/coreutils/literals.go +++ b/clients/go/coreutils/literals.go @@ -489,6 +489,10 @@ func MakeLiteralForType(t *core.LiteralType, v interface{}) (*core.Literal, erro case *core.LiteralType_Simple: newT := t.Type.(*core.LiteralType_Simple) strValue := fmt.Sprintf("%v", v) + if v == nil { + strValue = "" + } + if newT.Simple == core.SimpleType_STRUCT { if _, isValueStringType := v.(string); !isValueStringType { byteValue, err := json.Marshal(v) diff --git a/clients/go/coreutils/literals_test.go b/clients/go/coreutils/literals_test.go index e1a557a863..38e03f1de2 100644 --- a/clients/go/coreutils/literals_test.go +++ b/clients/go/coreutils/literals_test.go @@ -617,4 +617,14 @@ func TestMakeLiteralForType(t *testing.T) { _, err := MakeLiteralForType(literalType, "m") assert.Error(t, err) }) + + t.Run("Nil string", func(t *testing.T) { + var literalType = &core.LiteralType{Type: &core.LiteralType_Simple{Simple: core.SimpleType_STRING}} + l, err := MakeLiteralForType(literalType, nil) + assert.NoError(t, err) + assert.Equal(t, "", l.GetScalar().GetPrimitive().GetStringValue()) + l, err = MakeLiteralForType(literalType, "") + assert.NoError(t, err) + assert.Equal(t, "", l.GetScalar().GetPrimitive().GetStringValue()) + }) }