Compatibility issues with sprig dig function between 1.16 and 1.17 #877
-
|
Hello! Very new to this repo so looking for some advice on what may be causing the issues I am about to describe. I have a sample go program as follows: When using this program with expr-lang 1.16.9 I get: However, when upgrading to 1.17.X (while keeping sprig module the same) I get: Any thought what may be causing this? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
|
Hey! I wrote a small test case to try and reproduce this: func TestSprigDigCompatibility(t *testing.T) {
// Simulating sprig.GenericFuncMap() - a map containing functions
funcMap := map[string]any{
"dig": func(ps ...any) (any, error) {
// Simplified dig implementation - just return the default value
if len(ps) < 2 {
return nil, nil
}
return ps[len(ps)-2], nil
},
}
labels := map[string]any{
"some": map[string]any{
"label": map[string]any{
"io/creator-email": "test@example.com",
},
},
}
env := map[string]any{
"sprig": funcMap,
"labels": labels,
}
program, err := expr.Compile("sprig.dig('some', 'label', 'io/creator-email', nil, labels)", expr.Env(env))
require.NoError(t, err)
output, err := expr.Run(program, env)
require.NoError(t, err)
require.Nil(t, output) // Our simplified dig returns the default (nil)
// Print disassembly for debugging
fmt.Println("Disassembly:")
fmt.Println(program.Disassemble())
}Runs fine on v1.16.9, but fails on all tagged releases after to the same error you're seeing: But the good thing is that it runs fine on |
Beta Was this translation helpful? Give feedback.
-
|
Yes! I will release v1.17.7 very soon 🙌 |
Beta Was this translation helpful? Give feedback.
Yes! I will release v1.17.7 very soon 🙌