From 0d21000ece8fc1765968f1434d1676a32321202b Mon Sep 17 00:00:00 2001 From: Guilherme Cassolato Date: Tue, 22 Aug 2023 17:18:52 +0200 Subject: [PATCH] set default empty string to counter qualifiers ('wasm data items') to prevent selectors that fail to select a value to invalidate the limit --- pkg/rlptools/wasm_utils.go | 2 +- pkg/rlptools/wasm_utils_test.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/rlptools/wasm_utils.go b/pkg/rlptools/wasm_utils.go index d1e275645..3d9d14275 100644 --- a/pkg/rlptools/wasm_utils.go +++ b/pkg/rlptools/wasm_utils.go @@ -245,7 +245,7 @@ func dataFromLimt(limitIdentifier string, limit *kuadrantv1beta2.Limit) (data [] data = append(data, wasm.DataItem{Static: &wasm.StaticSpec{Key: limitIdentifier, Value: "1"}}) for _, counter := range limit.Counters { - data = append(data, wasm.DataItem{Selector: &wasm.SelectorSpec{Selector: counter}}) + data = append(data, wasm.DataItem{Selector: &wasm.SelectorSpec{Selector: counter, Default: common.Ptr("")}}) } return data diff --git a/pkg/rlptools/wasm_utils_test.go b/pkg/rlptools/wasm_utils_test.go index 9771679d3..7e1e0c77a 100644 --- a/pkg/rlptools/wasm_utils_test.go +++ b/pkg/rlptools/wasm_utils_test.go @@ -10,6 +10,7 @@ import ( gatewayapiv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" kuadrantv1beta2 "github.com/kuadrant/kuadrant-operator/api/v1beta2" + "github.com/kuadrant/kuadrant-operator/pkg/common" "github.com/kuadrant/kuadrant-operator/pkg/rlptools/wasm" ) @@ -318,6 +319,7 @@ func TestWasmRules(t *testing.T) { { Selector: &wasm.SelectorSpec{ Selector: "auth.identity.username", + Default: common.Ptr(""), }, }, },