FastAPI 0.143.3 Fixes Non-Finite Float Serialization in JSONL and SSE Streams

FastAPI·16 Oct 2026·2 min read

#fastapi

FastAPI has shipped 0.143.3, a small maintenance release that resolves a serialization edge case affecting streaming responses. The bug concerned non-finite floats — values such as NaN, Infinity and -Infinity — which were not being handled correctly when FastAPI emitted JSONL (newline-delimited JSON) or SSE (Server-Sent Events) output. Because these values are not valid JSON, streams carrying them could fail or produce malformed payloads for clients. This release fixes that behaviour.

The concrete changes in this patch:

  • Fixed non-finite float serialization in JSONL and SSE streams, so NaN, Infinity and -Infinity no longer break streaming responses (PR #16509 by @tiangolo).
  • Updated the Python code formatting across the Markdown documentation using Ruff, keeping examples consistent and lint-clean (PR #16505 by @tiangolo).

The streaming fix is the part most applications will care about. JSONL and SSE endpoints are commonly used for incremental output, such as streaming tokens from an LLM-backed service, pushing progress updates, or delivering log-style event feeds. Any of those pipelines can produce non-finite floats when computing ratios, averages, losses or metrics, so a single NaN reaching the serializer was enough to corrupt an otherwise healthy response and confuse downstream parsers. Developers building on FastAPI's StreamingResponse, or on streaming helpers layered on top of it, should upgrade to fastapi==0.143.3 to pick up the corrected encoding behaviour.

The documentation change is cosmetic for readers but useful for contributors, since it aligns code samples in the docs with the project's Ruff formatting rules and reduces diff noise in future documentation pull requests. With one functional bug fix and one housekeeping update, 0.143.3 is a low-risk upgrade recommended for anyone relying on streamed JSON responses.

Source: https://github.com/fastapi/fastapi/releases/tag/0.143.3

Related

auto-curated · source linked above← all news