Skip to content

Commit

Permalink
MakeLiteralForType shouldn't print <nil> for nil values (flyteorg#188)
Browse files Browse the repository at this point in the history
* Add max concurrency to launch plan & execution spec (flyteorg#186)

Signed-off-by: Haytham Abuelfutuh <[email protected]>

* MakeLiteralForType shouldn't print <nil> for nil values

Signed-off-by: Haytham Abuelfutuh <[email protected]>

* bump

Signed-off-by: Haytham Abuelfutuh <[email protected]>

Co-authored-by: Katrina Rogan <[email protected]>
  • Loading branch information
EngHabu and Katrina Rogan authored Jun 17, 2021
1 parent 4f4be4d commit ec8a7fa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions clients/go/coreutils/literals.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions clients/go/coreutils/literals_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
})
}

0 comments on commit ec8a7fa

Please sign in to comment.