Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All event_properties ignored if one key value is "None" #52

Closed
dxprog opened this issue Nov 6, 2023 · 3 comments
Closed

All event_properties ignored if one key value is "None" #52

dxprog opened this issue Nov 6, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@dxprog
Copy link

dxprog commented Nov 6, 2023

Expected Behavior

When sending an event via amplitude.track with a dictionary of event properties where one value might be None, expect that the None value is either serialized to null or deleted.

Current Behavior

If any value within a dictionary is None, no event properties are sent. I suspect this is also an issue for user_properties and group_properties, though have not verified. Per the object validation method, a None value would cause the entire object to fail.

Possible Solution

Add None type to the list of valid values and let the object serialize it to null. This can then be filtered out appropriately in charts or addressed in code if it's an incorrect value.

Steps to Reproduce

okay_event = BaseEvent(
  event_type='test event', 
  user_id='12345',
  event_properties={'requiredProp': 'this is never null', 'optionalProp': 'this is sometimes null'},
)
okay_event.get_event_body()
# {'user_id': '12345', 'event_type': 'test event', 'event_properties': {'requiredProp': 'this is never null', 'optionalProp': 'this is sometimes null'}}

fail_event = BaseEvent(
  event_type='test event', 
  user_id='12345',
  event_properties={'requiredProp': 'this is never null', 'optionalProp': None},
)
fail_event.get_event_body()
# {'user_id': '12345', 'event_type': 'test event'}

Environment

  • SDK Version: 1.1.3
  • Python Version: 3.11
  • OS Info: Ubuntu 20.04
@dxprog dxprog added the bug Something isn't working label Nov 6, 2023
@dxprog dxprog changed the title All event_properties ignored if on key value is "None" All event_properties ignored if one key value is "None" Nov 6, 2023
@sheepsy90
Copy link

I experience the same issue. I also belief that this is incorrect behavior.

@liuyang1520
Copy link
Contributor

Hi @dxprog , @sheepsy90 , thanks for reporting this!

It looks like a bug, and I am going to give it a try.

Thanks!

@liuyang1520
Copy link
Contributor

The fix has been merged and released in https://pypi.org/project/amplitude-analytics/1.1.4/, PTAL! Closing this issue now. Thanks for supporting Amplitude!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants