[bug]: Reading boolean off a string(variations) feature flag results in bad result.
raevilman opened this issue · 3 comments
Given
A feature flag with two variations ['red', 'blue'].
When
We try to get it with OpenFeature call as getBooleanValue
with defaultValue
set to true
.
Actual result
It results in false
Expected result
it should return default value true
as the flag isn't a of Boolean type.
Debugging
The code in question is at co.featbit.server.utils.checkType
case FLAG_STRING_TYPE:
if (requiredType == Boolean.class) {
return BooleanUtils.toBooleanObject(returnValue) == null;
}
...
Here, if returnValue
is 'red',
thus BooleanUtils.toBooleanObject(returnValue)
returns null
,
and final value returned is true
for the checkType
call.
but it should return false
IMO.
Because of which it fails to enter:
co.featbit.server.FBClientImp
if (requiredType != null && !Utils.checkType(flag.getVariationType(), requiredType, res.getValue())) {
Loggers.EVALUATION.warn("FB JAVA SDK: evaluation result {} didn't matched expected type {}", res.getValue(), requiredType);
return Evaluator.EvalResult.error(dv, REASON_WRONG_TYPE, res.getKeyName(), res.getName());
}
PS:
I can send a PR if you find the debugging info above correct.
Sorry, we didn't get the github notification in time for this issue. We will review the issue as soon as possible.
@raevilman the bug is fixed in https://github.com/featbit/featbit-java-sdk/releases/tag/v1.4.2
Thank you!