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

Empty subject attributes in python are empty tuples instead of None #211

Open
bennettandrews opened this issue Feb 21, 2025 · 0 comments · May be fixed by #212
Open

Empty subject attributes in python are empty tuples instead of None #211

bennettandrews opened this issue Feb 21, 2025 · 0 comments · May be fixed by #212

Comments

@bennettandrews
Copy link

We ran into an issue where we were dropping assignment events in our downstream logger due to unexpected subject attribute values. If a None value is passed into subject attributes, they come back as empty tuple in the AssignmentLogger such as user_id: () which does not conform to the expected type of subject_attributes: Dict[str, Union[str, int, float, bool, None]],.

We ended up adding:

return {
  k: None if v == () else v|
  for k, v in assignment_event.get("subjectAttributes", {}).items()
}

The issue seems to be in https://github.com/Eppo-exp/eppo-multiplatform/blob/main/eppo_core/src/pyo3.rs#L28. The rust Option<T> when None is converted back to python uses ().to_object(py) which will create an empty tuple object instead of py.None()

Example

Tested on eppo-sever-sdk 4.0.0 and 4.2.4

client = eppo_client.get_instance()
user = get_current_user()

variation = client.get_boolean_assignment(
    'show-new-feature',
    user.id,
    { 'country': None },
    False
)

With AssignmentLogger

class LocalAssignmentLogger(AssignmentLogger):
	def log_assignment(self, assignment_event: dict) -> None:
		subject_attributes = assignment_event.get("subjectAttributes", {})
		print(f"Subject attributes: {subject_attributes}")

Country comes back as ()

Subject attributes: {'country': () } 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant