Skip to content

Fix nested sanitization of datetime and NaN values#127

Merged
hownowstephen merged 5 commits into
mainfrom
fix/nested-sanitization
May 22, 2026
Merged

Fix nested sanitization of datetime and NaN values#127
hownowstephen merged 5 commits into
mainfrom
fix/nested-sanitization

Conversation

@hownowstephen
Copy link
Copy Markdown
Contributor

@hownowstephen hownowstephen commented May 22, 2026

Summary

  • _sanitize_value() only handled top-level dict values — datetime and NaN inside nested dicts or lists passed through unsanitized, causing TypeError during JSON serialization or silent data corruption
  • Added recursion into dict and list types in _sanitize_value()
  • 4 new tests covering nested dict, list, NaN, and deeply nested structures

Test plan

  • Nested dict with datetime converts to timestamp
  • List containing datetime values converts correctly
  • Nested dict with NaN converts to None
  • Deeply nested dict-in-list-in-dict handled
  • All 52 tests pass

🤖 Generated with Claude Code


Note

Low Risk
Low risk: limited to request payload sanitization, extending existing datetime/NaN handling to nested dicts/lists and backed by new unit tests.

Overview
Fixes payload sanitization so datetime and NaN values are converted even when nested inside dicts or lists before JSON requests are sent.

Adds recursive handling in ClientBase._sanitize_value() and extends the test suite with cases for nested dicts, lists, and deeply nested structures (plus minor test formatting cleanups).

Reviewed by Cursor Bugbot for commit 9d04324. Bugbot is set up for automated code reviews on this repo. Configure here.

datetime and NaN values nested inside dicts or lists were passed
through unsanitized because _sanitize_value() only handled flat
values. Add recursion for dict (via _sanitize()) and list types.
@hownowstephen hownowstephen merged commit 16e3f94 into main May 22, 2026
10 checks passed
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.

2 participants