Skip to content

Commit e2b7ef0

Browse files
committed
fix: upgrade Sprig to bring in bugfix. Fixes argoproj#15093
As @dmarquez-splunk discovered, the Sprig upgrade in argoproj#14307 introduced a regression when evaluating an expression that has a call to a variadic Sprig function with `nil`. This was fixed in expr-lang/expr#868, which was released as [v1.17.7](https://github.com/expr-lang/expr/releases/tag/v1.17.7). I also added a test case to prevent regressions. Signed-off-by: Mason Malone <651224+MasonM@users.noreply.github.com>
1 parent e991e6d commit e2b7ef0

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ require (
2121
github.com/dustin/go-humanize v1.0.1
2222
github.com/evanphx/json-patch v5.9.11+incompatible
2323
github.com/evilmonkeyinc/jsonpath v0.8.1
24-
github.com/expr-lang/expr v1.17.5
24+
github.com/expr-lang/expr v1.17.7
2525
github.com/gavv/httpexpect/v2 v2.16.0
2626
github.com/go-git/go-git/v5 v5.16.0
2727
github.com/go-jose/go-jose/v3 v3.0.4

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,8 @@ github.com/evilmonkeyinc/jsonpath v0.8.1 h1:W8K4t8u7aipkQE0hcTICGAdAN0Xph349Ltjg
276276
github.com/evilmonkeyinc/jsonpath v0.8.1/go.mod h1:EQhs0ZsoD4uD56ZJbO30gMTfHLQ6DEa0/5rT5Ymy42s=
277277
github.com/exponent-io/jsonpath v0.0.0-20210407135951-1de76d718b3f h1:Wl78ApPPB2Wvf/TIe2xdyJxTlb6obmF18d8QdkxNDu4=
278278
github.com/exponent-io/jsonpath v0.0.0-20210407135951-1de76d718b3f/go.mod h1:OSYXu++VVOHnXeitef/D8n/6y4QV8uLHSFXX4NeXMGc=
279-
github.com/expr-lang/expr v1.17.5 h1:i1WrMvcdLF249nSNlpQZN1S6NXuW9WaOfF5tPi3aw3k=
280-
github.com/expr-lang/expr v1.17.5/go.mod h1:8/vRC7+7HBzESEqt5kKpYXxrxkr31SaO8r40VO/1IT4=
279+
github.com/expr-lang/expr v1.17.7 h1:Q0xY/e/2aCIp8g9s/LGvMDCC5PxYlvHgDZRQ4y16JX8=
280+
github.com/expr-lang/expr v1.17.7/go.mod h1:8/vRC7+7HBzESEqt5kKpYXxrxkr31SaO8r40VO/1IT4=
281281
github.com/fatih/camelcase v1.0.0 h1:hxNvNX/xYBp0ovncs8WyWZrOrpBNub/JfaMvbURyft8=
282282
github.com/fatih/camelcase v1.0.0/go.mod h1:yN2Sb0lFhZJUdVvtELVWefmrXpuZESvPmqwoZc+/fpc=
283283
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=

util/template/replace_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ func Test_Replace(t *testing.T) {
4444
require.NoError(t, err)
4545
assert.Equal(t, toJSONString("bar"), r)
4646
})
47+
t.Run("Valid With Variadic Sprig Expression", func(t *testing.T) {
48+
r, err := Replace(ctx, toJSONString("{{=sprig.dig('status', nil, workflow)}}"), map[string]string{"workflow.status": "Succeeded"}, false)
49+
require.NoError(t, err)
50+
assert.Equal(t, toJSONString("Succeeded"), r)
51+
})
4752
t.Run("Valid WorkflowStatus", func(t *testing.T) {
4853
replaced, err := Replace(ctx, toJSONString(`{{=workflow.status == "Succeeded" ? "SUCCESSFUL" : "FAILED"}}`), map[string]string{"workflow.status": "Succeeded"}, false)
4954
require.NoError(t, err)

0 commit comments

Comments
 (0)