Closed
Description
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': () }
Metadata
Metadata
Assignees
Labels
No labels