Skip to content

Commit

Permalink
Add log message
Browse files Browse the repository at this point in the history
  • Loading branch information
nmayorsplit committed May 10, 2024
1 parent 90936af commit dc30b2c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions engine/grammar/condition.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
}
Expand Down
5 changes: 5 additions & 0 deletions engine/grammar/condition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions engine/grammar/split.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit dc30b2c

Please sign in to comment.