Skip to content

fix: sanitize datetime and NaN values inside tuple payloads - #139

Draft
Kayvan-Zahiri wants to merge 1 commit into
customerio:mainfrom
Kayvan-Zahiri:codex/sanitize-tuple-payloads
Draft

Kayvan-Zahiri wants to merge 1 commit into
customerio:mainfrom
Kayvan-Zahiri:codex/sanitize-tuple-payloads

Conversation

@Kayvan-Zahiri

Copy link
Copy Markdown

The shared serializer recursively converts datetimes to timestamps and NaN to null inside dictionaries and lists, but skips tuples. Requests already accepts tuples as JSON arrays, so an otherwise accepted tuple fails JSON preparation as soon as it contains a datetime or NaN. This affects profile attributes, event data, Track v2 batch attributes, and transactional message data before any request is sent.

Treat tuples like lists during recursive sanitization. The original containers are not modified; JSON array output for native scalar tuples stays unchanged.

Five new unittest cases exercise 40 public-call combinations: identify, track, batch, and send_email, each with connection pooling enabled and disabled, across tuple datetimes, tuple NaN, deeply mixed containers, and native-tuple/list controls. A local recording requests adapter captures prepared request bodies without contacting the API. Before the fix, 24 combinations error during JSON preparation; 16 controls pass. Afterward, all new cases pass. Full repository unittest suite:65 tests pass using the existing local HTTPS test server. Repository-wide Ruff lint/format and git diff --check pass. No live Customer.io request or email was sent during testing.

Developed with Codex assistance; reproduced and verified locally.

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