fix: not_regex should handle all value types like regex - #305
Conversation
|
This pairs with the exact/is_not consistency fix in #299 and is independent of it. The practical trigger is common: a not_regex flag condition on a numeric property (an ID, a version code, an age) that arrives as a JSON number, which becomes float64 in Go, currently errors instead of evaluating. Routing through valueToString keeps not_regex in step with regex for every value type. |
dustinbyrne
left a comment
There was a problem hiding this comment.
hey @eeshsaxena, thanks for another pull request here! i ran an agentic review for compatibility, and it had one minor finding i've described below. it's small enough in scope that it seems worth fixing.
|
also, your commits will need to be signed in order to be eligible for merge |
|
Good catch, thanks. Fixed: a On signing: understood, I'll get the commits signed so it's merge-eligible. |
The not_regex operator used a manual string/int type switch and returned an error for any other type, most notably float64 (what JSON numbers deserialize to), so it failed on a numeric property value even though regex handled the same value. Coerce both the pattern and the property value with valueToString, mirroring the regex operator, and add a regression test.
9136fe6 to
fa1d6b4
Compare
|
blocking: Preserve evaluation-service semantics for null — featureflags.go:1222 The feature-flags evaluation service represents an explicit JSON null as "null" during regex matching, so not_regex "^1" i fixed this issue and pushed changes with signed commits so its ready to be merged |
Problem
The
regexandnot_regexoperators handle value types differently.regexcoerces both sides withvalueToString, so it accepts strings, ints, floats, and bools:not_regexinstead uses a manualstring/inttype switch and returns an error for anything else:The important gap is
float64: JSON numbers deserialize tofloat64, so anot_regexcondition on a numeric property value errors out even though the same value works withregex:Fix
Make
not_regexmirrorregex, coercing both the pattern and the property value withvalueToString. This handles all value types and keeps the two operators consistent. AddedTestMatchPropertyNotRegexHandlesAllValueTypes(string, int, float64).Testing
go test .passes (full package suite, including the new test).