fix(python): preserve final JSON Lines records without a trailing newline
Why
The Python JSON Lines reader drops the final record when the response ends without a trailing newline. The EOF check uses position, but that cursor is reset to zero after each chunk. The remaining buffer is therefore never decoded. A single-record response can silently produce no events, and a malformed final record is silently discarded.
The JSON Lines format recommends a final newline but does not require one.
What changed
Check for non-whitespace buffered data at EOF in both synchronous and asynchronous reader templates, then pass it through the existing decoder. Empty streams and whitespace-only tails retain their existing behavior; malformed final JSON raises the decoder's error.
Add 50 offline regression cases to the existing Python primary streaming tests: newline/no-newline, multiple records, LF/CRLF, UTF-8, empty input, whitespace tails, malformed final JSON, and different byte-chunk boundaries. Add the jsonlResponses patch changeset using the repository command.
Regenerated the Python review SDK with the supported command; it contains no JSON Lines operation and produces no tracked diff. Separately generated a minimal synthetic JSON Lines SDK before and after the template change and regenerated the primary test SDK.
Testing
- Unmodified generated stream utility: 26 failed, 24 passed. Fixed generated utility: all 50 passed.
- The committed tests run unchanged from the generated primary SDK: 50 passed, six existing service-dependent tests deselected. Pytest reports one unknown
timeoutconfiguration warning because pytest-timeout is not installed in the isolated test environment. - Public methods of the independently generated synthetic SDK, through HTTPX MockTransport: 24 failed/24 passed before; all 48 passed after.
- Generated synthetic SDK: full mypy passes across 39 source files; wheel and source distribution build.
- Generator binary build,
npm run format,make check-template-pythonv2, review SDK regeneration/integrity validation, andgit diff --checkpass. make lintpassed its public-input guard, then stopped becausegolangci-lintis unavailable. The repository-wide lint gate and Docker-backed multi-target integration matrix are not claimed as passing.- No live service, account, or customer inputs. All responses and specifications are synthetic.
Public-safety check
- This change contains no credentials, customer documents, private repository URLs, private filesystem paths, or unredacted private logs.
- Title, body, comments, and commit messages name no customers or customer-derived identifiers, private paths or trackers, or workflow provenance, and are understandable without private context.
- Generated fixtures and review SDK changes are public-safe.
- I reviewed
git diff --check.
Summary by cubic
Fixes the Python JSON Lines reader dropping the final record when a response ends without a trailing newline. The EOF check relied on a position cursor that resets to zero after each chunk, so remaining buffered data was never decoded. Buffered non-whitespace data at EOF now passes through the existing decoder; empty streams and whitespace-only tails behave as before, and malformed final JSON raises the decoder's error instead of being silently discarded.
Adds 50 offline regression cases covering newline/no-newline, multiple records, LF/CRLF, UTF-8, empty input, whitespace tails, malformed final JSON, and chunk boundaries, plus a patch changeset for jsonlResponses.