diff --git a/internal/ingress/controller/template/configmap.go b/internal/ingress/controller/template/configmap.go index 481724793e..febf20be02 100644 --- a/internal/ingress/controller/template/configmap.go +++ b/internal/ingress/controller/template/configmap.go @@ -125,8 +125,11 @@ func ReadConfig(src map[string]string) config.Configuration { delete(conf, luaSharedDictsKey) lsd := splitAndTrimSpace(val, ",") for _, v := range lsd { - v = strings.ReplaceAll(v, " ", "") - results := strings.SplitN(v, ":", 2) + results := strings.SplitN(strings.ReplaceAll(v, " ", ""), ":", 2) + if len(results) != 2 { + klog.Errorf("Ignoring poorly formatted Lua dictionary %v", v) + continue + } dictName := results[0] size := dictStrToKb(results[1]) if size < 0 { diff --git a/internal/ingress/controller/template/configmap_test.go b/internal/ingress/controller/template/configmap_test.go index dad8416942..6c7468303b 100644 --- a/internal/ingress/controller/template/configmap_test.go +++ b/internal/ingress/controller/template/configmap_test.go @@ -390,6 +390,11 @@ func TestLuaSharedDictsParsing(t *testing.T) { entry: map[string]string{"lua-shared-dicts": "configuration_data: 10, my_random_dict:15 , another_example:2"}, expect: map[string]int{"configuration_data": 10240, "my_random_dict": 15360, "another_example": 2048}, }, + { + name: "invalid format", + entry: map[string]string{"lua-shared-dicts": "mydict: 10, invalid_dict 100"}, + expect: map[string]int{"mydict": 10240}, + }, { name: "invalid size value should be ignored", entry: map[string]string{"lua-shared-dicts": "mydict: 10, invalid_dict: 1a, bad_mb_dict:10mb"},