https://www.growthbook.io/ logo
s

square-restaurant-38765

07/06/2023, 11:48 AM
This message contains interactive elements.
This condition is giving false value -
Copy code
if (growthBook.isOn("discount")) {}
even though similar features are giving enabled response.
Hi all, just observed that even though above condition is false, i am getting the feature value for a user id.. it means only the condition part is not working..any idea ?
Also, when toggling to disabled i am getting default value..
h

helpful-application-7107

07/06/2023, 9:14 PM
All of this seems like the expected behavior. What is the configuration for
discount
?
s

square-restaurant-38765

07/06/2023, 9:15 PM
Here is the configuration
But, isOn should give me true value right ?
this way in future i wont be able to disable my feature.
h

helpful-application-7107

07/06/2023, 9:17 PM
Yeah, it looks like in this case
isOn
should always return true, since the value is always non-zero.
s

square-restaurant-38765

07/06/2023, 9:17 PM
Yes
Any idea ?
h

helpful-application-7107

07/06/2023, 9:26 PM
but when you call
growthBook.getFeatureValue("discount", 0);
in the same place it returns an Integer of 10 or 20?
s

square-restaurant-38765

07/06/2023, 9:26 PM
Yes
h

helpful-application-7107

07/06/2023, 9:39 PM
If it works for your other features, I'd have to think there's some difference in the configuration that is calling this. Very hard for me to know, but I can take a deeper look in a bit.
s

square-restaurant-38765

07/06/2023, 9:40 PM
Sure, please let me know if i can provide any info
b

better-magician-65629

07/06/2023, 10:11 PM
i just looked into this and it looks like there's a bug in the
FeatureResult#isOn
method. it has to do with all the numeric types in java (double vs. float vs. integer, etc.). here's a workaround until we get this fixed:
Copy code
FeatureResult<Float> donutPriceFeatureResult = growthBook.evalFeature("donut_price", Float.class);
System.out.printf("Donut price feature result %s\n", donutPriceFeatureResult);
System.out.printf("Donut price feature is on %s\n", donutPriceFeatureResult.isOn()); // there is a bug here (this is the one you found)
System.out.printf("Donut price feature is on %s\n", donutPrice != 0.0f); // workaround
s

square-restaurant-38765

07/06/2023, 10:41 PM
Thanks a lot @better-magician-65629 @helpful-application-7107 for helping me out !
b

better-magician-65629

07/06/2023, 11:20 PM
FYI a fix for this bug is available in 0.7.1
🙌 1