Hi there! I'm using the python SDK and just realiz...
# announcements
k
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
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
@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
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
Thanks so much @future-teacher-7046, that would be great!! I'll keep an eye on it to upgrade the sdk version then!
f
@kind-airplane-15946 New version is published now with the fix - 0.3.1
k
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
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
👍 thanks @future-teacher-7046