Repository navigation
Conversation
download_results and the batch CLI opened result files without an explicit encoding, so results containing non-ASCII text (any non-English model output, emoji, accented characters) raised UnicodeEncodeError on Windows and were written as mojibake on any other non-UTF-8 locale. Open the result files with encoding="utf-8", matching the existing BytesIO path in BatchRequest.save_to_file which already encodes as UTF-8. Add regression tests for both the OpenAI and Anthropic providers that download non-ASCII results and assert the file round-trips as UTF-8.
Contributor
Author
|
Rebased on |
Collaborator
jxnl-oai
added a commit
that referenced
this pull request
Nov 5, 2026
Consolidates OpenAI batch request error handling. Current main already retrieves both output and error files for completed jobs, preserves the raw record and uses provider type before code. Keep that public contract, preserve string errors at either location, and report unsuccessful HTTP status codes when the provider omits the error body. The full provider code is available in raw_data when both type and code are present. Validation: 90 offline tests passed across parsing, retrieval, file downloads and malformed records. The OpenAI and Anthropic download tests from #2804 verify that non-ASCII results are written as UTF-8 on platforms with an ASCII default. The production encoding fix shipped in #2708. Consolidates #2820, #2822, #2825, #2657 and #2804.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
#2667 made the batch module write result files as UTF-8, which fixed the
UnicodeEncodeErroron Windows and the mojibake on non-UTF-8 locales. That fix landed without a regression test that exercises non-ASCII content, so the behavior is easy to break again (for example by droppingencoding=or re-addingensure_ascii).This PR adds that coverage. It originally also carried the encoding fix itself; after rebasing on
main, the source change is identical to what #2667 shipped, so the only remaining diff is the tests.Tests
One regression test per provider in
tests/coverage:Café ☕ 東京Both tests raise
UnicodeEncodeErrorunder a cp1252 locale if the UTF-8 encoding is removed, and pass against currentmain. The fulltests/coveragebatch suites stay green.