diff --git a/engine/grammar/condition.go b/engine/grammar/condition.go index a1f9463a..fbdd3a36 100644 --- a/engine/grammar/condition.go +++ b/engine/grammar/condition.go @@ -25,6 +25,7 @@ func NewCondition(cond *dtos.ConditionDTO, ctx *injection.Context, logger loggin } matcherObjs, err := processMatchers(cond.MatcherGroup.Matchers, ctx, logger) if err != nil { + // At this point the only error forwarded is UnsupportedMatcherError return nil, err } @@ -44,6 +45,7 @@ func processMatchers(condMatchers []dtos.MatcherDTO, ctx *injection.Context, log if err == nil { matcherObjs = append(matcherObjs, m) } else { + logger.Debug("error in BuildMaycher, reason: ", err.Error()) if _, ok := err.(datatypes.UnsupportedMatcherError); ok { return nil, err } diff --git a/engine/grammar/condition_test.go b/engine/grammar/condition_test.go index 2350fcee..86a8c9b8 100644 --- a/engine/grammar/condition_test.go +++ b/engine/grammar/condition_test.go @@ -5,6 +5,7 @@ import ( "github.com/splitio/go-split-commons/v5/dtos" "github.com/splitio/go-split-commons/v5/engine/grammar/matchers" + "github.com/splitio/go-split-commons/v5/engine/grammar/matchers/datatypes" "github.com/splitio/go-toolkit/v5/logging" ) @@ -193,6 +194,10 @@ func TestConditionUnsupportedMatcherWrapperObject(t *testing.T) { if err == nil { t.Error("err should not be nil") } + + if _, ok := err.(datatypes.UnsupportedMatcherError); !ok { + t.Error("err should be UnsupportedMatcherError") + } } func TestConditionMatcherWithNilStringWrapperObject(t *testing.T) { diff --git a/engine/grammar/split.go b/engine/grammar/split.go index 7bc14936..9214e93a 100644 --- a/engine/grammar/split.go +++ b/engine/grammar/split.go @@ -37,6 +37,7 @@ func processConditions(splitDTO *dtos.SplitDTO, ctx *injection.Context, logger l for _, cond := range splitDTO.Conditions { condition, err := NewCondition(&cond, ctx, logger) if err != nil { + logger.Debug("Overriding conditions due unexpected matcher received") return conditionReplacementUnsupportedMatcher } conditionsToReturn = append(conditionsToReturn, condition)