Closed
Description
When running the following expression, it returns in the error interface conversion: interface {} is nil, not string (1:9)
We would like to handle this gracefully, as the query
parameter are optional that we're matching on. We prefer not to wrap it in string()
, as our customer may create their own expression, and prefer to have this expression as clean as possible.
Is there any way to combat this, with for instance AllowUndefinedVariables
? Or can expr-lang
be modified to allow contains
queries etc. on possible nil
types?
env := map[string]interface{}{
"query": map[string]interface{}{
"another_query": "test",
},
}
expression := "query.b contains 'test'"
prg, _ := expr.Compile(expression, expr.Env(env))
result, err := expr.Run(prg, env)
fmt.Println(result)
fmt.Println(err)
Output:
interface conversion: interface {} is nil, not string (1:9)
| query.b contains 'test'
Metadata
Metadata
Assignees
Labels
No labels