diff --git a/llx/builtin_map.go b/llx/builtin_map.go index 6db4fe1161..3184232a54 100644 --- a/llx/builtin_map.go +++ b/llx/builtin_map.go @@ -783,7 +783,10 @@ func dictDifferenceV2(e *blockExecutor, bind *RawData, chunk *Chunk, ref uint64) return &RawData{Type: bind.Type, Error: errors.New("cannot compute difference of lists, argument is not a list")}, 0, nil } - filters := arg.Value.([]interface{}) + filters, ok := arg.Value.([]interface{}) + if !ok { + return &RawData{Type: bind.Type, Error: errors.New("tried to call function with a non-array, please make sure the argument is an array")}, 0, nil + } var res []interface{} var skip bool diff --git a/resources/packs/core/core_test.go b/resources/packs/core/core_test.go index 124f3529ef..b2bd59608c 100644 --- a/resources/packs/core/core_test.go +++ b/resources/packs/core/core_test.go @@ -1101,6 +1101,18 @@ func TestDict_Methods_Contains(t *testing.T) { p + "params['string-array'].contains('a')", 1, true, }, + { + p + "params['string-array'].containsOnly(['c', 'a', 'b'])", + 1, true, + }, + { + p + "params['string-array'].containsOnly(['a', 'b'])", + 1, false, + }, + // { + // p + "params['string-array'].containsOnly('a')", + // 1, false, + // }, { p + "params['string-array'].none('a')", 1, false,