You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
If you have an expression like mylistundef[0] == 'hi', and 'mylistundef' is undefined, you get an ambiguous error "fails with no such attribute: id: 2, names: []".
To Reproduce
Check which components this affects: (not sure)
Sample expression and input that reproduces the issue:
mylistundef[0] == 'hi'
Test setup:
// test case in gofunctestList() error {
env, err:=cel.NewEnv(
cel.Variable("mylist", cel.ListType(cel.StringType)),
)
iferr!=nil {
returnerr
}
ast, issues:=env.Parse(`mylistundef[0] == 'hi'`)
iferr:=issues.Err(); err!=nil {
returnerr
}
program, err:=env.Program(ast)
varmap:=map[string]any{}
varmap["mylist"] = []string{"hi"}
val, _, err:=program.Eval(varmap)
iferr!=nil { // fails with no such attribute: id: 2, names: []returnerr
}
match, ok:=val.Value().(bool)
if!ok {
returnfmt.Errorf("type convert failed: type is %v", val.Type())
}
returnnil
}
funcTestList(t*testing.T) {
iferr:=testList(); err!=nil {
t.Error(err)
}
}
Expected behavior
There should be a clear error, such as "mylistundef is undefined"
The text was updated successfully, but these errors were encountered:
Resolve returns the first error it sees. Which is dereference of the deepest variable. Ex: 'foo.bar.baz[0]' will error in this order: no such attr: 2 -> no such attr baz -> no such attr bar -> no such attr foo.
And what you end up with is a vague "no such attribute: id: 2".
Describe the bug
If you have an expression like
mylistundef[0] == 'hi'
, and 'mylistundef' is undefined, you get an ambiguous error "fails with no such attribute: id: 2, names: []".To Reproduce
Check which components this affects: (not sure)
Sample expression and input that reproduces the issue:
Test setup:
Expected behavior
There should be a clear error, such as "mylistundef is undefined"
The text was updated successfully, but these errors were encountered: