-
Notifications
You must be signed in to change notification settings - Fork 0
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
Evaluate targeting rules with semver string format (FF-1433) #38
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job knocking this out!
{ | ||
operator: OperatorType.GTE, | ||
attribute: 'version', | ||
value: '1.0.0', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about test data that makes sure sem ver comparisons are at play (vs string ones). Such as GTE 1.6.4
and then you can compare it against 1.12.3
or something like that
valid as validSemver, | ||
gt as semverGt, | ||
lt as semverLt, | ||
gte as semverGte, | ||
lte as semverLte, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I appreciate the more explicit renaming
if (value != null) { | ||
switch (condition.operator) { | ||
case getMD5Hash(OperatorType.GTE): | ||
if (conditionValueType === OperatorValueType.SEM_VER) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not your code, but seems kind of crazy w have to duplicate the switch statement. If easy, consider cleaning it up by changing from a switch
to a Map
or something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aaron do you mean the duplication between the evaluateCondition
and evaluateObfuscatedCondition
functions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah (had to expand the PR to confirm). Whenever I see the same business logic change being made in multiple places in a PR like that it triggers some spidey senses 🕷️ 🕸️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aaron I gave it a shot but really didn't like the way the code turned out - a complicating factor is the difference behavior in the lt, gt..
and the one of, not on off
branches. Want to pair for a few minutes?
labels: mergeable
Fixes: #issue
Motivation and Context
RAC API will start returning targeting rule values containing semver strings (https://github.com/Eppo-exp/eppo/pull/8697).
Our SDKs need to be able to parse these strings and perform rule evaluation on them.
Description
The operations
lt, gt, lte, gte
now only apply to numeric values; insert a higher priority step to check if the value is a semver string; if so apply the comparison with it. Otherwise fall through and attempt to evaluate using numerics.behavior of un-upgraded SDKs
They will continue to assume that only numeric values will be present for the
lt, gt, lte, gte
operations - thecompareNumber
function will return false if both sides of the comparison are not numbers.How has this been tested?
New unit tests.