Skip to content

fix: preserve caller properties during event serialization - #81

Draft
Kayvan-Zahiri wants to merge 1 commit into
amplitude:mainfrom
Kayvan-Zahiri:codex/preserve-event-properties-on-serialization
Draft

Kayvan-Zahiri wants to merge 1 commit into
amplitude:mainfrom
Kayvan-Zahiri:codex/preserve-event-properties-on-serialization

Conversation

@Kayvan-Zahiri

Copy link
Copy Markdown

Summary

Calling get_event_body() currently edits dictionaries supplied to a public event: it removes None entries, converts enum values, and recursively truncates strings in nested dictionaries/lists. For example, serializing BaseEvent("example", event_properties=properties) removes properties["empty"] when its value is None. Returned nested containers also alias the original event data.

Copy dictionary-valued fields before payload normalization. This preserves the existing outgoing payload format while leaving caller-owned and stored event properties intact. Other field types keep their existing handling.

Add seven public serialization tests covering event/user/group properties, groups, nested containers, returned-body independence, repeated serialization, and falsy-value controls. Five tests fail before the change, while two controls pass.

Validation: the repository's full unittest command passes all 125 tests on Python 3.12. Changed files compile and git diff --check passes. No hosted Amplitude requests or full Python-version matrix run. No repository lint configuration was found.

AI-assisted contribution; maintainer review pending.

Checklist

  • PR title follows conventional commit format.
  • Does your PR have a breaking change?: No intended payload-format change; callers no longer observe serialization modifying their property dictionaries.

This branch has not been deployed

No deployments
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 this pull request may close these issues.

1 participant