Skip to content

fix(studio): split S3 JSON Lines manifests on LF only - #16723

Closed
hsusul wants to merge 2 commits into
unslothai:mainfrom
hsusul:fix/s3-jsonl-unicode-separators
Closed

hsusul wants to merge 2 commits into
unslothai:mainfrom
hsusul:fix/s3-jsonl-unicode-separators

Conversation

@hsusul

@hsusul hsusul commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Fixes #16721.

Why

S3 audio dataset preparation reads JSON Lines manifests with str.splitlines(). That method also breaks on U+0085, U+2028 and U+2029, which JSON allows unescaped inside strings. One transcript with such a character aborts preparation with JSONDecodeError, though the Hugging Face JSON loader reads the same file fine.

What changed

  • _rewrite_json_manifest splits JSON Lines records on "\n" only. Text mode already turns CRLF into LF.
  • A regression test covers all three characters in .jsonl and in JSON Lines stored as .json.

Scope

This covers the JSON Lines branch of the S3 manifest rewriter. Single JSON documents and CSV manifests stay as they are.

Blast Radius

The change touches S3 manifests in JSON Lines form. A manifest without these characters splits into the same records as before.

Verification

  • Before the fix, the new test failed in all 6 cases with JSONDecodeError: Unterminated string.
  • After the fix, pytest studio/backend/tests/test_s3_audio_dataset.py studio/backend/tests/test_s3_dataset.py reported 72 passed.
  • datasets.load_dataset("json", ...) read a CRLF manifest with U+2028 as 2 rows, and the new split returned the same 2 rows.

@danielhanchen

Copy link
Copy Markdown
Member

Thank you for the PR! This made the same fix as #16725, which has now been merged, so I'm closing this one as a duplicate. Your separator test cases are covered there too (all three characters, .jsonl and .json, LF and CRLF). Appreciate you jumping on this so quickly.

iam-knoit pushed a commit to SynhalaAI/unsloth that referenced this pull request Nov 6, 2026
…unslothai#16725)

Fixes unslothai#16721.

S3 audio dataset preparation aborts when a JSON Lines transcript
contains literal U+0085, U+2028, or U+2029. Python's `str.splitlines()`
treats those characters as record boundaries even inside JSON strings.

Split on LF after text-mode newline normalization. The regression test
checks that both rows retain their transcripts and point to the
downloaded audio for `.jsonl` and multi-record `.json` manifests with LF
and CRLF.

This draft overlaps unslothai#16723 and carries explicit CRLF regression
coverage.

## Verification

- Four regression cases failed before the fix and passed afterward.
- 70 tests passed across `test_s3_audio_dataset.py` and
`test_s3_dataset.py`. An additional eight local diagnostics using
Hugging Face datasets 4.3.0 passed.
- Repository formatter, scoped Ruff check, and `git diff --check`
passed.

---------

Co-authored-by: Daniel Han <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Studio S3 audio JSONL preparation fails on Unicode separators inside transcripts

2 participants