Skip to content

Skip empty CRLF lines in JSONLines - #443

Merged
mattt merged 1 commit into
huggingface:mainfrom
Pybsama:skip-empty-crlf-json-lines
Dec 1, 2026
Merged

mattt merged 1 commit into
huggingface:mainfrom
Pybsama:skip-empty-crlf-json-lines

Conversation

@Pybsama

@Pybsama Pybsama commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Update JSONLines.append(_:) and JSONLines.finish() so lines containing only \r (such as blank \r\n lines or a trailing \r at EOF) are skipped as empty, while keeping trailing \r intact on non-empty lines.
  • Previously, blank \r\n lines emitted [0x0D] instead of nil, causing HTTPTransport.fetchStream (used by OllamaLanguageModel.streamResponse) to pass Data("\r".utf8) to JSONDecoder and fail with HTTPTransportError(kind: .decodingError).
  • Add regression tests in JSONLinesTests.emptyCRLFLinesAreSkipped and HTTPTransportTests.streamedEmptyCRLFLinesAreSkipped.

Verification

  • swift format lint --strict --recursive . (Swift 6.3.3): passed
  • swift test --disable-index-store --filter "JSONLinesTests|HTTPTransportTests": 4 failures reproduced pre-fix -> 14/14 passed across 2 suites post-fix
  • swift test --skip-build --disable-index-store --skip OllamaLanguageModelTests: 1,105/1,105 passed across 113 suites

@mattt
mattt merged commit d8c2231 into huggingface:main Dec 1, 2026
14 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