Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Log an error if a non-64 datatype is used. #270

Merged
merged 2 commits into from
Sep 10, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Log an error if a non-64 datatype is used.
JamieSinn committed Sep 10, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 1c2ea43f59338182c28a9d1392867195f035dea9
25 changes: 24 additions & 1 deletion bucketing/segmentation.go
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ package bucketing

import (
"fmt"
"github.com/devcyclehq/go-server-sdk/v2/util"
"math"
"regexp"
"strings"
@@ -57,7 +58,28 @@ func checkCustomData(filter *CustomDataFilter, data map[string]interface{}, clie
} else {
dataValue = data[filter.DataKey]
}

isNot64Bit := false
switch dataValue.(type) {
case uint8:
isNot64Bit = true
case uint16:
isNot64Bit = true
case uint32:
isNot64Bit = true
case uint:
isNot64Bit = true
case int8:
isNot64Bit = true
case int16:
isNot64Bit = true
case int32:
isNot64Bit = true
case float32:
isNot64Bit = true
}
if isNot64Bit {
util.Errorf("Custom data key %s is not a 64 bit type. Please use a 64 bit type", filter.DataKey)
}
if operator == "exist" {
return checkValueExists(dataValue)
} else if operator == "!exist" {
@@ -68,6 +90,7 @@ func checkCustomData(filter *CustomDataFilter, data map[string]interface{}, clie
} else {
return checkStringsFilter(v, filter.UserFilter)
}

} else if _, ok := dataValue.(float64); ok && filter.DataKeyType == "Number" {
return checkNumbersFilterJSONValue(dataValue, filter.UserFilter)
} else if v, ok := dataValue.(bool); ok && filter.DataKeyType == "Boolean" {