test: Castiron reports fail on Windows with default GBK encoding
Confirm this is a repository issue, not an API service issue
- [x] This affects the Node SDK repository's Castiron reporting tool. It is not an OpenAI API failure or a published SDK runtime defect.
Describe the bug
On Windows with Python's default CP936/GBK encoding, the Castiron reporter can successfully compute an ok report, then crash while writing its own Markdown summary.
The report contains fixed Unicode text such as ✅, ⚠, and −, but write_report() writes summary.md with Path.write_text(summary) without an explicit encoding. On this machine the result is:
custom_code_report.py, line 942, in write_report
(out / "summary.md").write_text(summary)
UnicodeEncodeError: 'gbk' codec can't encode character '\u2705' in position 201: illegal multibyte sequence
The JSON report already says "status": "ok", but summary.md is empty and the real report CLI exits 1. This prevents local reporting under an ordinary non-UTF-8 Windows Python configuration.
To reproduce
At main commit b4e8176a7a9c598fee0615548c77d637a6990f40, use the existing regression without modifying it:
Set-Location scripts/castiron
python -c "import locale, sys; print(locale.getencoding(), sys.flags.utf8_mode)"
# cp936 0
python -B -X utf8=0 -m unittest test_custom_code_github.GitHubReportTests.test_trusted_report_recomputes_pr_output_in_a_bare_repository
# FAILED (errors=7), at summary.md writing in each subcase
python -B -X utf8=1 -m unittest test_custom_code_github.GitHubReportTests.test_trusted_report_recomputes_pr_output_in_a_bare_repository
# OK
This test builds real local Git fixtures and runs the actual reporting implementation, with GitHub responses supplied offline. It needs no credentials or live API calls.
I also invoked the real custom_code_report.py report --repo <fixture> --base <base> --head <base> --require-head-hash --out <output> CLI against one unchanged, valid local fixture from GitTestCase.baseline(). Only the child interpreter's UTF-8 mode differed:
| Repetition | Python mode | CLI exit | report.json status | summary.md |
|---|---|---|---|---|
| 1 | utf8=0 | 1 | ok | 0 bytes |
| 1 | utf8=1 | 0 | ok | 1122 bytes |
| 2 | utf8=0 | 1 | ok | 0 bytes |
| 2 | utf8=1 | 0 | ok | 1122 bytes |
Expected behavior / root cause
A successfully computed local report should be emitted without depending on the machine's legacy locale encoding. Report artifacts need an explicit encoding; CLI stdout behavior also needs to be considered because the same Unicode summary is written there immediately afterward.
Running this particular command with python -X utf8=1 is a verified workaround. This does not make the entire Windows Castiron test suite pass: unrelated symlink-privilege and executable-mode fixture failures remain separate and are not part of this report.
The reporter is generated/shared Castiron code, so the durable correction likely belongs in its shared source followed by regeneration, rather than a manual vendored SDK patch. No policy, ownership, budget checks, or tests were weakened.
Environment
- OS: Windows x64, default Python locale encoding CP936/GBK
- Python: 3.12.10
- Node: v24.19.0
- pnpm: 11.5.1
- Repository version: main at
b4e8176a7a9c598fee0615548c77d637a6990f40(package.jsoncurrently says 7.39.0; this report concerns repository tooling, not npm 7.39.0)
Thanks for the detailed report and for taking the time to isolate the encoding issue and verify a workaround. Castiron and the associated repository scripts support our internal SDK generation workflow and are not a publicly supported tool or surface. We’re closing this as out of scope for public SDK support, but we appreciate the thorough investigation.