Repository navigation
Description
This was generated by AI during triage (lane: triage-decide, self-observation).
Lane: triage-decide. Category: operational (silent data-fidelity defect in durable tracker content).
Triggering example
Fetching #657's body via gh issue view 657 --json body --jq '.body' > file.md (Windows/Git-Bash, LANG=en_US.UTF-8, gh 2.95.0, git 2.54.0.windows.1) and later writing it back with gh issue edit 657 --body-file <path> (or the REST equivalent gh api ... -X PATCH -F body=@<path>) round-trips real UTF-8 em-dashes (—, U+2014) into the classic double-encoding mojibake — (U+00E2 U+20AC U+201D) for a subset of occurrences.
Discovered mid-cycle 2 (2026-07-22) while checking off two more #657 sweep lines: a live fetch of #657 via gh api repos/.../issues/657 + Python json.load (a decode path proven correct) showed the live GitHub-stored body already contained 51 mojibake instances alongside 80 correctly-encoded em-dashes — i.e. the corruption is not a local-display artifact, it is byte-for-byte wrong content actually stored on GitHub. Root cause of the ORIGINAL corruption is not fully isolated (could be gh/jq's interaction with Git-Bash's redirect codepage on this machine, or could pre-date this session from another lane's write) — but the round-trip path this repo's own standing rules mandate (--body-file for any comment/body containing backticks or $, itself a fix for a different corruption bug — see #657's own line ~370 finding) is a proven vector for this second, distinct corruption class on at least this machine: gh issue view --json body --jq '.body' > file (bash > redirect) is suspect; gh api ... -q '.body' > file reproduces it too. gh api <endpoint> > file.json followed by Python json.load() does NOT reproduce it (correct decode) — meaning the corruption is introduced somewhere in --json/--jq/bash-redirect text handling, not in the raw HTTP/JSON layer itself.
Observed vs expected
- Observed: targeted substring
—present in file content after agh ... --json body --jq '.body' > filefetch, and (separately, already live on GitHub before this session touched it) present in lane sweep: triage — week of 7/20 (rolling paper-cut batch) #657's actual stored body — meaning some earlier write already pushed this corruption to GitHub. - Expected: every character round-trips byte-identical through
ghCLI fetch → local file →ghCLI write-back, with no silent transcoding.
Impact
Silent — no error, no warning, both gh issue view --json and gh issue edit --body-file exit 0. Any lane (not just this one) that fetches a comment/issue body via --json ... --jq '.body' > file, edits it, and writes it back via --body-file risks corrupting every em-dash (and potentially other non-ASCII punctuation not yet observed in this specific body — only em-dash appeared in #657's content, so other characters are unconfirmed, not ruled out) in the untouched portions of that body. This is exactly the class of "silent-wrong output" this lane's own standing rules single out (durable-audit-trail fidelity: #502's fused telemetry comment and #657's sweep checklist are both edited via this exact pattern every cycle).
Fix applied this cycle (workaround, not a root-cause fix)
Fetched #657 via gh api <endpoint> > raw.json (no --jq), loaded with Python json.load() (confirmed-correct UTF-8 decode), replaced the literal 3-char mojibake substring — with —, wrote back with encoding='utf-8', pushed via gh api ... -X PATCH -F body=@<path> (capital -F, not -f, per the adjacent #943-class gotcha this lane already tracks). Verified 0 mojibake / 131 correct em-dashes post-fix. This workaround does not identify or fix the root cause in gh's --json/--jq/bash-redirect path.
Category
bug (tooling/environment) — silent data corruption on a specific character class through the exact write pattern this lane's and other lanes' standing rules mandate for all non-trivial comment/body content.
Suggested fix direction (not prescriptive — needs investigation)
Isolate whether the corruption originates in gh's own stdout encoding, --jq's UTF-8 handling, or Git-Bash's > redirect codepage on Windows; once isolated, either avoid --json ... --jq '.body' > file in favor of gh api <endpoint> > file.json + a JSON-aware read (proven clean in this incident), or find the correct gh/environment flag/setting that fixes the redirect path directly. Any lane's standing rules that prescribe the --body-file-from-fetched-body pattern should link this issue until resolved.
Work-class: C3 (bug-fix-shaped) — attended triage 2026-07-23, operator-ratified. 🤖
Activity
kyle-sexton commentedon Jul 22, 2026
This was generated by AI during triage.
Lane: triage-decide (self-observation follow-up). Investigation outcome: the filed hypothesis is disproven; the real corruption vector is isolated.
TL;DR
The fetch path this issue accuses (
gh issue view --json body --jq '.body' > file,gh api ... --jq '.body' > file, and the piped variant) does not corrupt em-dashes on this machine. It is byte-faithful, locale-independent, and byte-identical to the "proven clean" JSON-aware decode. The real—mojibake comes from decoding a fetched UTF-8 body with a tool that defaults to Windows cp1252 — on this box that is Python'sopen()/json.load(open(path))(text mode) and PowerShell'sGet-Contentwithout-Encoding utf8. The corruption is a downstream-decode defect in an ad-hoc read step, not ingh/jq/ the bash>redirect.Repro 1 — fetch path is byte-faithful (disproves the filed hypothesis)
#657is currently clean (the prior cycle's write-back workaround fixed it): 134 correct em-dashes, 0 mojibake. Fetched its body four ways and compared bytes:——gh issue view 657 --json body --jq '.body' > fd3821b…c565c3gh api repos/.../issues/657 --jq '.body' > fd3821b…c565c3gh issue view 657 --json body -q '.body' | python -c "sys.stdin.buffer…"d3821b…c565c3gh api repos/.../issues/657 > raw.json+json.loads(open(rb).read())A, B, D are md5-identical.
A == C-body + b'\n'exactly (the 1-byte diff is jq-r's trailing newline). So--json --jq > fileequals the JSON-aware decode. Locale made zero difference:LANG=C.UTF-8andLANG=Cboth produced files byte-identical to A. jq (pipe and file) and the bash redirect, tested in isolation on a controlled em-dash, each preserved\xe2\x80\x94exactly. No invocation shape reproduced fetch-side corruption.Repro 2 — the actual mechanism (reproduced to the exact documented byte sequence)
locale.getpreferredencoding()= cp1252 on this machine (Python 3.14,LANG=en_US.UTF-8in Git-Bash does not change Python's Windows default). Reading a clean UTF-8 body file with Python's defaultopen()(noencoding=):That output byte sequence
c3a2 e282ac e2809dis exactly the—(U+00E2 U+20AC U+201D) mojibake this issue documents. Withencoding='utf-8'the same round-trip is clean (0 mojibake, 1 correct em-dash). The mechanism is a UTF-8 stream read as cp1252 and re-encoded as UTF-8 — a read-side decode error, which is why it is invisible togh,jq, and the redirect (all of which only ever move bytes).Why the prior cycle misdiagnosed it
The prior cycle observed 51 mojibake in a live fetch of
#657and attributed it to the fetch path — but it never compared the fetch against a known-clean baseline. A faithful fetch of already-corrupt stored bytes shows mojibake too. Their evidence is equally consistent with (and, given Repro 1, is actually) faithful reproduction of content some earlier ad-hoc write had already corrupted via the cp1252 read above. Their "workaround" (gh api > file.json+json.loads(bytes)+encoding='utf-8'write) worked not because it avoided the fetch path, but becausejson.loads()on bytes auto-detects UTF-8 per RFC 8259 and the write forced UTF-8 — i.e. it happened to use a correct decode.Reproduction limitation (stated up front)
The prior cycle's exact "51 mojibake in a fetch" observation cannot be re-run:
#657is now clean. The disproof is therefore indirect but airtight — (a) the fetch is byte-faithful on clean content across all four shapes; (b) the cp1252 read reproduces the exact documented byte pattern. I could not pin the specific original corrupting command, because it was an in-session ad-hoc read (see next section), not a committed code path — so it leaves no artifact.Is the footgun instantiated in this repo's code? (grep result)
Grepped the committed body read-modify-write surface. The GitHub tracker adapter (
plugins/work-items/tools/work-item-tracker/adapters/github/*.sh) is entirely bash using--body-file -(stdin) — byte-faithful, no cp1252 layer, not a vector. The onlyjson.load(open())hits are eval assertions indocs/topics/babysit-prs-migration/PLAN.mdover local ASCII files (not body content). TheGet-Content-without--Encodinghits are all machine-health cache/catalog reads, unrelated to issue bodies. No committed code instantiates the footgun — the original#657corruption came from a prior lane cycle's ad-hoc in-session Python patch of the body (exactly thepython -c "…open(path)…"a triage agent types on the fly), which is unfixable-in-code and only preventable by convention.Recommended fix direction
The issue's own "Suggested fix direction" (avoid
--json --jq > file; prefergh api > file.json+ JSON-aware read) is built on the wrong diagnosis and should be corrected, not adopted: avoiding the fetch shape fixes nothing, andjson.load(open(path))(text mode) is itself the footgun on Windows. The correct convention is transport-agnostic:Where it belongs:
plugins/work-items/tools/work-item-tracker/adapters/github/README.md— the repo's authoritative gh-CLI mechanics reference (it already documents the--body-fileWRITE identity, the-Fvs-f#943-class gotcha, and read-modify-write). Add the UTF-8-decode note adjacent to the--body-fileread-modify-write section (~lines 130-176), as a sibling to the existing gotchas. This is a documentation/convention change with no code fix required (no committed code is vulnerable), so it is low-risk and defaultable.Decision defaulted: document the transport-agnostic "force-UTF-8-on-decode" convention in
plugins/work-items/tools/work-item-tracker/adapters/github/README.md(adjacent to the--body-fileread-modify-write section) and correct this issue's misframed suggested-fix; no code fix needed — veto before mergekyle-sexton commentedon Jul 24, 2026
This was generated by AI on operator direction.
Superseded — this item was already ratified and should not have been queued.
The earlier first-drain ratification request on this issue was raised in error. The admission gate dispatches a C3 bug-fix-shaped item when it carries either its own recorded ratification or a completed first drain — and this issue already carried recorded ratification in its body from attended triage on 2026-07-23. The drain cycle applied the blanket first-drain rule without first reading bodies for an existing ratification, so it queued an item that was already admitted.
Restored to the autonomous frontier:
agent-readyre-applied,needs-humanremoved. No human action is required, and this issue no longer appears in the attended queue's ratify view.kyle-sexton commentedon Jul 25, 2026
kyle-sexton commentedon Jul 25, 2026
This was generated by AI while working #1037.
Spent scratch probe (round-trip encoding verification). Result folded into the PR; no content here.
docs(work-items): force UTF-8 wherever a body edit leaves the gh pipe…
docs(work-items): force UTF-8 wherever a body edit leaves the gh pipe…
docs(work-items): force UTF-8 wherever a body edit leaves the gh pipe…
Merge origin/main into fix/1253-triage-priority-label-live-resolution