fix(source-control): document/export PYTHONUTF8=1 for fetch-all-pr-comments.sh consumers#1344
fix(source-control): document/export PYTHONUTF8=1 for fetch-all-pr-comments.sh consumers#1344kyle-sexton wants to merge 1 commit into
Conversation
…mments.sh consumers `fetch-all-pr-comments.sh`'s UTF-8 JSON output commonly carries non-ASCII bytes (bot badge images, reaction emoji) from bot review comments. Reproduced directly on Windows: a Python consumer that opens the output, or reads this script's stdout, without an explicit UTF-8 encoding inherits the interpreter's default ANSI code page (cp1252) and raises UnicodeDecodeError on those bytes. This repo's own consumer (babysit_findings.py, via babysit-readiness-gate.sh) already pins encoding="utf-8" explicitly and is unaffected, so the gap is external/downstream Python consumers. `fetch-all-pr-comments.sh --help` now documents the PYTHONUTF8=1 (PEP 540) requirement for Windows consumers that don't pin the encoding themselves. babysit-readiness-gate.sh was the one babysit_python caller that parses this script's comment-JSON schema and lacked the `export PYTHONUTF8=1` convention the two bin/ babysit wrappers (source-control-babysit-merge, source-control-babysit-resolve-thread) already apply; it now sets it too, closing the inconsistency. Adds regression tests: --help documents the requirement, the gate's source pins the export, and a stubbed-interpreter behavioral test proves the exported value actually reaches the Python child process. Closes #597 Co-Authored-By: Claude Sonnet 5 (200K context) <noreply@anthropic.com>
|
Claude finished @kyle-sexton's task in 4m 8s —— View job PR Review
Summary: Docs-only + defense-in-depth
|
|
Claude finished @kyle-sexton's task in 1m 55s —— View job Security Review
No security vulnerabilities found. I reviewed all six changed files for injection surfaces, unsafe env-var handling, privilege escalation, credential exposure, and dangerous shell patterns. Here is what I examined and why each surface is clean:
|
This was generated by AI during work-loop execution.
Closes #597
Summary
fetch-all-pr-comments.sh's UTF-8 JSON output commonly carries non-ASCII bytes (bot badgeimages, reaction emoji) from bot review comments. Reproduced directly on this Windows machine: a
Python consumer that opens the output, or reads this script's stdout, WITHOUT an explicit UTF-8
encoding inherits the interpreter's default ANSI code page (cp1252) and raises
UnicodeDecodeErroron those bytes — confirmed with a minimal repro (open(path)+json.load,no
encoding=kwarg,PYTHONUTF8unset).This repo's own consumer (
babysit_findings.py, invoked frombabysit-readiness-gate.sh) alreadypins
encoding="utf-8"explicitly on every file/subprocess read and reconfigures stdout/stderr toUTF-8 at runtime (
configure_stdio()), so it is unaffected — the real gap is external/downstreamPython consumers that don't pin the encoding themselves. Two changes, matching the issue's own
"implementer's call" framing (doc it, or set it internally — both are mechanical):
fetch-all-pr-comments.sh --helpnow documents thePYTHONUTF8=1(PEP 540) requirement for aWindows Python consumer that doesn't pin
encoding="utf-8"itself.babysit-readiness-gate.sh— the onebabysit_pythoncaller that parses this script'scomment-JSON schema and was missing the
export PYTHONUTF8=1convention the twobin/babysitwrappers (
source-control-babysit-merge,source-control-babysit-resolve-thread) alreadyapply — now sets it too, closing the inconsistency (belt-and-suspenders; not required by the
explicit
encoding="utf-8"calls already in place, but matches the established pattern).Docs-only + a defense-in-depth env export; no behavior change to the JSON schema or exit codes.
Test plan
open(path)(noencoding=) +json.loadon anemoji-laden fixture with
PYTHONUTF8unset on this Windows machine raisesUnicodeDecodeError: 'charmap' codec can't decode byte 0x8d ...— confirms the cp1252 rootcause described in source-control:babysit-prs: fetch-all-pr-comments.sh output needs PYTHONUTF8=1 to parse on Windows (emoji/cp1252 mismatch) #597.
babysit_findings.pyviababysit-readiness-gate.sh) isNOT affected either way (it already pins
encoding="utf-8"), by running the same emoji fixturethrough it with
PYTHONUTF8explicitly unset:findings=2 classified=1, no crash.bash plugins/source-control/scripts/fetch-all-pr-comments.sh --help— new "Windows Pythonconsumers" section renders correctly;
usage()'ssedrange updated to include it.bash plugins/source-control/scripts/fetch-all-pr-comments.test.sh— 19/19 pass (17 pre-existing--helpdocumentsPYTHONUTF8=1andUnicodeDecodeError).bash plugins/source-control/scripts/babysit-readiness-gate.test.sh— 65/65 pass (63pre-existing + 2 new: source pins
export PYTHONUTF8=1, and a behavioral test with a stubbedpy -3interpreter proving the exported value actually reaches the Python child process, notjust present as dead source text).
shellcheck --rcfile .shellcheckrcon all four changed shell files — clean.typos,editorconfig-checkeron all changed files — clean.markdownlint-cli2onCHANGELOG.md—Summary: 0 issues in 0 files.bash scripts/validate-plugins.sh— all plugin manifests and the catalog validated (versionbump 0.26.2 → 0.26.3 checked).
Related
Refs #568 — background: the
bash fetch-all-pr-comments.sh <N> > file.jsonstdout-capture patternthis issue's Windows repro builds on.
🤖 Generated with Claude Code