https://www.growthbook.io/ logo
#announcements
Title
# announcements
k

kind-airplane-15946

08/01/2022, 4:24 PM
Hi there! I'm using the python SDK and just realized about an unexpected behavior that I'd like to share When the id attribute used for hashing and the splitting criteria is: • An empty string,
''
, then it is filtered out from the experiment, and the callback function doesn't run, and the feature value is the default one. Expected behavior. • A null value,
None
, then it is NOT filtered out from the experiment, the callback function runs, and the feature value is assigned based on the hashing function and splitting logic. I find it kind of unexpected behaviour, as I would expect the same behavior as if it was an empty string WDYT?
f

future-teacher-7046

08/01/2022, 5:07 PM
Hi Jorge, that does sound like a bug we should fix.
Ah, I think I know why. We cast attribute values to a string first and it's being cast to "None" instead of an empty string.
k

kind-airplane-15946

08/01/2022, 5:36 PM
@future-teacher-7046 it seems so, and I believe that it is this code line the one that takes the
None
value and makes it
'None'
It seems like a bug isn't it? So the expected behavior would be casting the
None
to an empty string, isn't it? This way, the empty string, and the null value will behave the same way
f

future-teacher-7046

08/01/2022, 6:43 PM
yes, I think if we just change it to this it should work:
Copy code
str(self._attributes[attr] or "")
I can fix this and add an automated test case for it today
k

kind-airplane-15946

08/01/2022, 7:24 PM
Thanks so much @future-teacher-7046, that would be great!! I'll keep an eye on it to upgrade the sdk version then!
f

future-teacher-7046

08/01/2022, 8:10 PM
@kind-airplane-15946 New version is published now with the fix - 0.3.1
k

kind-airplane-15946

08/02/2022, 7:33 AM
Lovely news, thanks so much!
BTW @future-teacher-7046 do you think the same issue might apply also to the ruby SDK? Part of our backend is in ruby and that team uses the Ruby SDK
f

future-teacher-7046

08/02/2022, 11:37 AM
It's possible. I added a new test case to our test suite, so I can add that to Ruby as well to check. I think most languages already treat null as an empty string.
k

kind-airplane-15946

08/04/2022, 6:41 AM
👍 thanks @future-teacher-7046
18 Views