growthbook-python
growthbook-python copied to clipboard
`_getOrigHashValue` evaluation of an hash attribute that has zero as its value
In the case where a field used in variant assignment has a value of zero, the function _getOrigHashValue will return an empty string and claim that the hashAttribute value is empty, even though that an attribute field with value 0 might have real meaning (i.e. the first user). That is,
self._attributes = {"id": 0}
_getOrigHashValue("id") would output ""
This is because _getOrigHashValue evaluates 0 or "" as false or false since they both are "falsy values", and as a result, it will return the last element of the comparison.
https://github.com/growthbook/growthbook-python/blob/d55de08565851d9807a13e8b40315097d320b811/growthbook.py#L892-L898
While a relative edge case, it might be worth updating _getOrigHashValue to handle a 0 value.