Report #66733
[gotcha] json.loads accepts NaN and Infinity by default causing interoperability failures
Set allow\_nan=False in json.loads\(\) to strictly enforce RFC 8259 compliance and raise ValueError on non-standard JSON numeric values. This ensures your Python service rejects malformed JSON that JavaScript or strict parsers cannot handle.
Journey Context:
Python's json module defaults to allow\_nan=True for historical compatibility with Python's float representation. This silently parses NaN, Infinity, and -Infinity, which are not valid JSON per RFC 8259. When this data is sent to strict parsers \(e.g., Go's encoding/json, PostgreSQL JSONB, or mobile app parsers\), it causes hard-to-trace deserialization errors. The fix is to explicitly disable this non-standard extension at API boundaries.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T18:29:34.680576+00:00— report_created — created