Skip to content

docs(work-items): force UTF-8 wherever a body edit leaves the gh pipeline - #1340

Merged
kyle-sexton merged 4 commits into
mainfrom
fix/1037-gh-body-utf8-decode
Jul 25, 2026
Merged

kyle-sexton merged 4 commits into
mainfrom
fix/1037-gh-body-utf8-decode

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

Closes #1037

Summary

The GitHub adapter documents read-modify-write shapes that fetch an issue/comment body, edit it,
and write it back. #1037 filed those as a corruption vector: em-dashes (U+2014) coming back as
U+00E2 U+20AC U+201D, silently, with every command exiting 0.

The issue's own investigation comment disproved the filed diagnosis, and this PR ships the
corrected convention rather than the one the issue body suggests. Both halves were re-verified
empirically on this machine before writing (see Test plan):

  • The gh transports are byte-faithful. --json/--jq, gh api, the bash > redirect, and
    --body-file only move bytes. A real em-dash pushed through a full comment round-trip
    (-F body=@file -> --jq '.body' > file -> -F body=@file -> refetch) came back byte-identical
    to the source. The pipelines in the adapter README need no encoding flag and are unchanged.
  • The corruption is a downstream decode. It enters when an ad-hoc step decodes those bytes with
    a tool whose default is a legacy code page — the body's UTF-8 read as Windows ANSI and re-encoded,
    then written back over the good copy.

So the new gotcha is transport-agnostic: keep body edits inside the byte-faithful pipeline, and
where an ad-hoc step is unavoidable, state the encoding on both sides of it.

Two Windows defaults decode this way, both named with their version scope so the note does not rot:

Surface Default Remedy
Python open(), no encoding= locale encoding (ANSI code page) through 3.14 encoding='utf-8', .decode('utf-8'), or PYTHONUTF8=1
Windows PowerShell 5.1 Get-Content ANSI code page -Encoding utf8

PEP 686 (Final, Python 3.15) flips the Python default to UTF-8,
and PowerShell 6+ already defaults to utf8NoBOM — which is exactly why the guidance is "state it
explicitly" rather than "check your version".

The write half is version-split deliberately. On Windows PowerShell 5.1, Set-Content -Encoding utf8
prepends a BOM and utf8NoBOM does not exist as a value — and by the byte-faithfulness established
above, --body-file would carry that U+FEFF straight into the stored body. That path gets
[IO.File]::WriteAllText($p, $s, (New-Object Text.UTF8Encoding $false)) instead. This was a review
finding on the first draft of this PR, caught and verified before it shipped.

No behavior change: documentation plus the version/CHANGELOG bump the repo's parity gate requires.
No committed code in this repo instantiates the footgun — every --body-file read-modify-write here
is bash/jq with no decode step, which the diff asserts rather than assumes.

Test plan

Every claim in the new gotcha was reproduced on this machine (Windows 11, Git Bash, gh 2.95.0,
Python 3.14.6 with locale.getencoding() -> cp1252, pwsh 7.6.3, Windows PowerShell 5.1.26100),
byte-inspected with od -tx1 rather than eyeballed:

  • Corruption mechanism. Clean UTF-8 e2 80 94 read with Python's default open() and
    re-encoded -> c3 a2 e2 82 ac e2 80 9d — the exact byte sequence tooling: gh CLI --json/--jq body fetch + bash redirect silently mojibake-corrupts UTF-8 em-dashes on write-back (durable tracker content at risk) #1037 documents. Clean under
    encoding='utf-8', under .decode('utf-8'), and under PYTHONUTF8=1.
  • PowerShell version split. Windows PowerShell 5.1 Get-Content (no -Encoding) reproduced the
    same mojibake; pwsh 7.6.3 was clean by default. This is why the note is version-scoped instead of
    blanket "PowerShell corrupts".
  • PS 5.1 write-side BOM. Set-Content -Encoding utf8 emitted ef bb bf ...; utf8NoBOM was
    rejected outright (not a valid enum value in 5.1); WriteAllText with UTF8Encoding $false was
    clean. Confirms the version-split remedy above.
  • Transport round-trip (end-to-end, live). Posted a scratch comment on tooling: gh CLI --json/--jq body fetch + bash redirect silently mojibake-corrupts UTF-8 em-dashes on write-back (durable tracker content at risk) #1037 containing a real
    em-dash via -F body=@file, fetched it back through the accused path
    (gh api ... --jq '.body' > file), wrote it back via -F body=@file, and refetched: 1 em-dash,
    0 mojibake, byte-identical to source (md5 match after trailing-newline normalization). The
    scratch comment was tombstoned afterward.
  • This PR's own bytes. The diff is about encoding corruption, so the committed blobs were
    checked directly, not by inspection: 0 mojibake sequences, 0 CR bytes, no BOM, valid UTF-8
    (iconv -f UTF-8 -t UTF-8) in the git index.
  • Repo gates, locally: markdownlint-cli2 0 issues, typos exit 0, editorconfig-checker
    exit 0, check-changelog-parity.sh --check and --check-bump origin/main both exit 0.

Related

This PR was authored by AI (autonomous work-loop lane).

@claude

claude Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 1m 36s —— View job


PR Review

  • Gather context and read changed files
  • Review plugin.json version bump
  • Review CHANGELOG.md entry
  • Review README.md gotcha section (correctness, formatting, alignment)
  • Check alignment with CLAUDE.md / repo guidelines
  • Post findings

Overall: looks good with one correctness nit in the Python remedies.

plugin.json — version bump

0.24.1 → 0.24.2 is the right patch increment for a documentation-only change. No issues.

CHANGELOG.md

Entry is well-scoped and follows the repo's established Keep a Changelog conventions (including the repo-local Documentation section heading, consistent with [0.24.1]). References #1037. No issues.

README.md gotcha — correctness

The bulk of the new gotcha is technically accurate and well-scoped:

One issue: the .read().decode('utf-8') shorthand is incomplete and would fail as written.

Line 337:

`open(path, encoding='utf-8')` or `.read().decode('utf-8')` (or run under `PYTHONUTF8=1`)

.read().decode('utf-8') calls .decode() on the return value of .read(). In Python 3, .read() on a text-mode file returns a str, and str has no .decode() method — this raises AttributeError: 'str' object has no attribute 'decode'. The pattern only works when the file is opened in binary mode ('rb'), but that's not stated.

The correct full form is open(path, 'rb').read().decode('utf-8'). Without the 'rb', the snippet is a broken example in a document specifically about encoding correctness.

Fix this →

Alignment with repo guidelines

  • No hardcoded paths, no project-specific values — rule satisfied (documentation only).
  • No PII or secrets in the diff.
  • Version bumped with explicit semver — satisfied.
  • PR title follows Conventional Commits (docs(work-items): …) — satisfied.
  • Fresh-docs mandate: the cited URLs (PEP 686, locale.getencoding, Get-Content 5.1 and 7.x, gh issue edit) are all primary sources and are listed as verified this session in the PR body.

The single blocking issue is the incomplete .read().decode('utf-8') example. Everything else is ready to merge once that's corrected.

@claude

claude Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 42s —— View job


Security Review — PR #1340

  • Read PR diff and changed files
  • Analyze for security vulnerabilities
  • Post findings

No security issues found.

This PR is a pure documentation change across three files:

File Change
plugin.json Semver patch bump 0.24.1 → 0.24.2
CHANGELOG.md Changelog entry for the version
adapters/github/README.md New cross-cutting gotcha about UTF-8 body-edit safety

No executable code, no workflow modifications, no permission changes, no new dependencies or action pins, no secrets or credential handling, and no new external trust delegations are introduced. The code snippets in the new gotcha (open(path, encoding='utf-8'), Get-Content -Encoding utf8, [IO.File]::WriteAllText(...)) are documentation examples only — none are executed at runtime by the plugin. The PowerShell WriteAllText snippet is a well-formed .NET call with no injection surface; $p and $s are consumer-supplied variables in an ad-hoc context the doc is advising on, not plugin-executed code.

The guidance added actually reduces corruption risk for consumers doing out-of-pipeline body edits, which is a net positive for data integrity.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3d4987116e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@claude

claude Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 1m 25s —— View job


Security Review — PR #1340

  • Load tools
  • Fetch PR diff
  • Read changed files
  • Analyze for security vulnerabilities
  • Post findings

No security issues found.

This PR changes three files, all documentation or metadata:

File Change
plugin.json Semver patch bump 0.24.1 → 0.24.2
CHANGELOG.md Changelog entry for [0.24.2]
adapters/github/README.md New cross-cutting gotcha about UTF-8 body-edit safety

Surfaces checked:

  • Injection (command, path, template): The new gotcha adds four code snippet examples in prose: open(path, encoding='utf-8'), open(path, 'rb').read().decode('utf-8'), Get-Content -Encoding utf8, and [IO.File]::WriteAllText($p, $s, (New-Object Text.UTF8Encoding $false)). All are documentation only — none are executed at runtime by the plugin. The PowerShell WriteAllText snippet uses $p and $s as consumer-supplied variables in the ad-hoc context the doc is advising on; no injection surface exists in a static prose example.
  • Token / secret / credential handling: None introduced or referenced.
  • GitHub Actions patterns: No workflow files changed. No pull_request_target, workflow_run, run: block script injection, or permissions: widening.
  • Supply-chain / dependency pins: No new dependencies, action references, or version pins added.
  • Permission changes: None.
  • File encoding integrity: The new content was diffed directly from the git index. No BOM, no \r bytes, and no mojibake sequences appear in the committed diff — consistent with the PR body's claimed iconv / od verification.
  • External links: The single new external link (https://peps.python.org/pep-0686/) points to the Python Software Foundation's canonical PEP index — no redirects or third-party trust delegation.

The guidance added reduces data-corruption risk for consumers doing out-of-pipeline body edits; it is a net positive for data integrity with no new attack surface.

@claude

claude Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 1m 27s —— View job


PR Review — #1340

  • Read changed files and PR diff
  • Verify the binary-mode fix applied in the latest commit
  • Review overall correctness and alignment
  • Post findings

The prior review finding is resolved. This PR is ready to merge.

Binary-mode fix (latest commit — 1721a16)

The correctness nit flagged by both the earlier Claude review and the Codex review has been addressed. Line 337 now reads:

`open(path, encoding='utf-8')` or `open(path, 'rb').read().decode('utf-8')` (or run under

open(path, 'rb').read().decode('utf-8') is self-contained and correct in Python 3: binary mode ('rb') returns bytes, and bytes.decode('utf-8') is well-defined. The previous form omitted the 'rb', leaving .decode() on a str which raises AttributeError.

Remaining content — all correct

plugin.json: 0.24.1 → 0.24.2 is the right patch increment for a doc-only change.

CHANGELOG.md: Entry follows the repo's Keep a Changelog conventions, uses the repo-local Documentation section heading (consistent with [0.24.1]), and references #1037.

README.md gotcha — technical claims:

Claim Verdict
gh transports (--json/--jq, gh api, >, --body-file) are byte-faithful ✅
Corruption path: UTF-8 read as ANSI, re-encoded, written back silently ✅
Em-dash U+2014 → U+00E2 U+20AC U+201D byte sequence ✅ (documented in #1037)
Python open() no-encoding = locale encoding (ANSI code page through 3.14) ✅
PEP 686 makes UTF-8 the default only in 3.15+ ✅
PS 5.1 Get-Content defaults to ANSI; PS 6+ defaults to utf8NoBOM ✅
PS 5.1 -Encoding utf8 prepends a BOM ✅
utf8NoBOM not a valid enum value in PS 5.1 ✅
[IO.File]::WriteAllText($p, $s, (New-Object Text.UTF8Encoding $false)) emits UTF-8 without BOM ✅
PYTHONUTF8=1 enables UTF-8 mode (since Python 3.7) ✅

Repo guidelines: No hardcoded paths, no PII/secrets, explicit semver bump, Conventional Commits PR title — all satisfied.

No issues found. The PR is correct, well-scoped, and aligned with the repo guidelines.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1721a16a9a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@kyle-sexton

Copy link
Copy Markdown
Member Author

Review pass resolved — 1721a16a

Two independent reviewers (Codex inline, Claude PR review) raised the same single finding, and it was valid:

.read().decode('utf-8') would fail as written. Following it literally after a text-mode open(path) raises AttributeError: 'str' object has no attribute 'decode' — verified by running it, not by reading it:

$ python -c "open(p).read().decode('utf-8')"
AttributeError: 'str' object has no attribute 'decode'

$ python -c "open(p,'rb').read().decode('utf-8')"   # -> e2 80 94, clean

A broken snippet inside a note about encoding correctness is worse than no snippet, so it now spells out the binary-mode open it was silently assuming: open(path, 'rb').read().decode('utf-8').

Kept rather than dropped, because reading bytes and decoding them is the form that generalizes to a body already in memory (an API response, a pipe) — it just had to show its 'rb'.

No other findings. The security review returned clean (documentation only; no executable code, workflow, permission, or dependency changes). All 25 checks pass on the updated head.

This was generated by AI (autonomous work-loop lane).

@kyle-sexton
kyle-sexton force-pushed the fix/1037-gh-body-utf8-decode branch from 1721a16 to b907b0a Compare July 25, 2026 17:53
@claude

claude Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 2m 15s —— View job


PR Review — #1340 (sync: b907b0a)

  • Load tools
  • Read README.md around line 338 — assess Codex -Raw finding
  • Verify technical validity of the fix — confirmed
  • Attempted push — denied (permissions); reported as finding below
  • Post final review

One remaining correctness issue — same class as the prior binary-mode fix.

README.md line 338 — Get-Content missing -Raw

Permalink

Current text prescribes:

$s = Get-Content -Encoding utf8
[IO.File]::WriteAllText($p, $s, (New-Object Text.UTF8Encoding $false))

Get-Content without -Raw returns a string[] — one element per line, with all line terminators stripped. When PowerShell coerces a string[] to the String contents parameter of WriteAllText, it joins elements with $OFS (a space by default), turning a multi-line body into one space-separated line. Every line break in the issue/PR body is silently destroyed before --body-file ever sees the file.

-Raw (available since PS 3.0, fully supported in 5.1) returns a single multiline string, preserving line terminators.

Fix: change Get-Content -Encoding utf8 → Get-Content -Raw -Encoding utf8 on line 338.

Fix this →

Everything else — correct

Check Verdict
plugin.json patch bump 0.24.1 → 0.24.2 ✅
CHANGELOG.md entry, Keep a Changelog format, Documentation heading ✅
Python open(path, 'rb').read().decode('utf-8') (binary-mode fix from prior commit) ✅
PYTHONUTF8=1 as an alternative ✅
PEP 686 / Python 3.15+ version scoping ✅
PS 5.1 ANSI default vs PS 6+ utf8NoBOM version scoping ✅
PS 5.1 -Encoding utf8 BOM hazard, utf8NoBOM invalid, WriteAllText workaround ✅
Repo guidelines (no hardcoded paths, no PII, Conventional Commits title, fresh-docs mandate) ✅

The -Raw fix is the only remaining blocker. It's a one-word insertion on line 338. Note: I applied it locally (daea826) but the push was rejected by repository permissions — it needs to be committed directly to the branch.

@claude

claude Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 1m 3s —— View job


Security Review — PR #1340

  • Load tools
  • Fetch PR diff
  • Read changed files
  • Analyze for security vulnerabilities
  • Post findings

No security issues found.

This PR changes three files, all documentation or metadata:

File Change
plugin.json Semver patch bump 0.24.2 → 0.24.3
CHANGELOG.md Changelog entry for [0.24.3]
adapters/github/README.md New cross-cutting gotcha about UTF-8 body-edit safety

Surfaces checked:

  • Injection (command, path, template): The new gotcha adds three code snippet examples in prose: open(path, encoding='utf-8'), open(path, 'rb').read().decode('utf-8'), Get-Content -Encoding utf8, and [IO.File]::WriteAllText($p, $s, (New-Object Text.UTF8Encoding $false)). All are static documentation — none are executed at runtime by the plugin. The $p/$s variables in the PowerShell WriteAllText snippet are consumer-supplied variables in the ad-hoc write context the doc is advising on; there is no injection surface in a static prose example.
  • Token / secret / credential handling: None introduced or referenced.
  • GitHub Actions patterns: No workflow files changed. No pull_request_target, workflow_run, run: block script injection, permission widening, or new action references.
  • Supply-chain / dependency pins: No new dependencies, action references, or version pins added.
  • Permission changes: None.
  • File encoding integrity: The committed diff contains no BOM, no \r bytes, and no mojibake sequences — consistent with the PR body's claimed iconv/od verification.
  • External links: The single new external link (https://peps.python.org/pep-0686/) points to the Python Software Foundation's canonical PEP index — no redirects or third-party trust delegation.

The guidance added reduces data-corruption risk for consumers doing out-of-pipeline body edits, which is a net positive for data integrity with no new attack surface.


@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b907b0a93e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

kyle-sexton and others added 2 commits July 25, 2026 14:01
…line

The GitHub adapter's read-modify-write shapes fetch an issue/comment body,
edit it, and write it back. The `gh` transports involved (`--json`/`--jq`,
`gh api`, the bash `>` redirect, `--body-file`) only move bytes, so those
pipelines never transcode. An ad-hoc step that decodes the fetched bytes
does transcode when its default is a legacy code page: the body's UTF-8 is
read as Windows ANSI and re-encoded, and the corrupted copy is written back
over the good one with every command exiting 0.

Record it as a cross-cutting gotcha naming the two Windows defaults that
decode this way (Python `open()` without `encoding=`, Windows PowerShell 5.1
`Get-Content`) and the explicit encoding to state on each side. The write
half is version-split because Windows PowerShell 5.1 has no `utf8NoBOM` and
its `-Encoding utf8` prepends a BOM that `--body-file` would then carry into
the stored body.

Closes #1037

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01NE8W4XPPVfZVCGBW2GYgyH
`.read().decode('utf-8')` raises AttributeError when followed literally
after a text-mode `open(path)` — `str` has no `.decode`. In a note about
encoding correctness the shorthand is worse than none, so spell out the
binary-mode open it assumed.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01NE8W4XPPVfZVCGBW2GYgyH
@kyle-sexton
kyle-sexton force-pushed the fix/1037-gh-body-utf8-decode branch from b907b0a to af553ea Compare July 25, 2026 18:02
@claude

claude Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 3m 33s —— View job


PR Review — #1340 (sync: af553ea)

  • Gather context and read changed files
  • Review the latest commit (af553ea) — binary-mode decode fix: applied correctly ✅
  • Check if -Raw PowerShell fix was applied — not applied
  • Assess latest Codex finding — Python write-side encoding — valid
  • Fix attempt — push rejected (repository permissions); findings posted below

Two correctness issues remain. Both were flagged by prior reviewers and not addressed in af553ea.

1. Get-Content still missing -Raw (line 338–339)

Permalink

Current:

Get-Content -Encoding utf8

Without -Raw, Get-Content returns a string[] — one element per line, all terminators stripped. When PowerShell coerces that string[] into the String contents parameter of WriteAllText, it joins with $OFS (a space by default), collapsing a multi-line issue body to a single space-separated line. -Raw (available since PS 3.0; fully supported in 5.1) returns a single multiline string.

Fix: Get-Content -Raw -Encoding utf8

This was raised by both Codex (commit 1721a16a) and the prior Claude review (b907b0a). The prior Claude agent prepared a commit but could not push.

2. Python write-side encoding absent (line 336–338)

Permalink

The text states: "state the encoding on both sides of any ad-hoc step" — but the Python examples cover only the read side. A subsequent open(path, 'w') still uses the locale codec (ANSI) on Windows, re-introducing the same corruption on the way out before --body-file ever reads the file.

The PS 5.1 write side (WriteAllText) is correctly shown; the Python write side is absent.

Fix: add open(path, 'w', encoding='utf-8') alongside the read examples.

This was raised by Codex against commit b907b0a and not addressed in af553ea.


Suggested minimal fix (both issues, lines 337–339)

Change:

  `open(path, encoding='utf-8')` or `open(path, 'rb').read().decode('utf-8')` (or run under
  `PYTHONUTF8=1`); PowerShell `Get-Content -Encoding utf8`. Writing back from Windows PowerShell 5.1 needs

To:

  read with `open(path, encoding='utf-8')` or `open(path, 'rb').read().decode('utf-8')` (or
  `PYTHONUTF8=1`), write with `open(path, 'w', encoding='utf-8')`; PowerShell
  `Get-Content -Raw -Encoding utf8`. Writing back from Windows PowerShell 5.1 needs

Fix this →


Everything else — correct

Check Verdict
plugin.json patch bump to 0.24.4 ✅
CHANGELOG.md entry, Keep a Changelog format, Documentation heading ✅
gh byte-faithfulness claim ✅
Corruption mechanism (UTF-8 read as ANSI, re-encoded) ✅
Em-dash byte sequence U+00E2 U+20AC U+201D ✅
Python open(path, 'rb').read().decode('utf-8') binary-mode fix (af553ea) ✅
PYTHONUTF8=1 as an alternative ✅
PEP 686 / Python 3.15+ version scoping ✅
PS 5.1 ANSI default vs PS 6+ utf8NoBOM version scoping ✅
PS 5.1 -Encoding utf8 BOM hazard, utf8NoBOM invalid, WriteAllText workaround ✅
Repo guidelines (Conventional Commits title, no hardcoded paths, no PII, fresh-docs mandate) ✅

The two findings above are the only remaining blockers. Both are one-line or near-one-line fixes.

@claude

claude Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 50s —— View job


Security Review — PR #1340

  • Load tools
  • Fetch PR diff (af553ea)
  • Read changed files
  • Analyze for security vulnerabilities
  • Post findings

No security issues found.

This PR changes three files, all documentation or metadata:

File Change
plugin.json Semver patch bump 0.24.3 → 0.24.4
CHANGELOG.md Changelog entry for [0.24.4]
adapters/github/README.md New cross-cutting gotcha about UTF-8 body-edit safety

Surfaces checked:

  • Injection (command, path, template): The new gotcha adds code snippet examples in prose: open(path, encoding='utf-8'), open(path, 'rb').read().decode('utf-8'), Get-Content -Encoding utf8, and [IO.File]::WriteAllText($p, $s, (New-Object Text.UTF8Encoding $false)). All are static documentation — none are executed at runtime by the plugin. The $p/$s variables in the PowerShell WriteAllText snippet are consumer-supplied variables in the ad-hoc write context the doc is advising on; there is no injection surface in a static prose example.
  • Token / secret / credential handling: None introduced or referenced.
  • GitHub Actions patterns: No workflow files changed. No pull_request_target, workflow_run, run: block script injection, permission widening, or new action references.
  • Supply-chain / dependency pins: No new dependencies, action references, or version pins added.
  • Permission changes: None.
  • File encoding integrity: The committed diff contains no BOM, no \r bytes, and no mojibake sequences — consistent with the PR body's claimed iconv/od verification.
  • External links: The single new external link (https://peps.python.org/pep-0686/) points to the Python Software Foundation's canonical PEP index — no redirects or third-party trust delegation.

The guidance added reduces data-corruption risk for consumers doing out-of-pipeline body edits, which is a net positive for data integrity with no new attack surface.

@kyle-sexton

Copy link
Copy Markdown
Member Author

Rebased onto current main — mergeable: MERGEABLE (head af553ead)

Rebased twice; the conflict was never in the substance of this change. Both times it was the same shape: another work-items PR merged first and claimed the patch version I had already written, so plugin.json and the CHANGELOG.md heading collided.

Resolved by composing rather than choosing — the other PR's entry is preserved verbatim and mine stacks above it:

version claimed outcome
first push 0.24.2 taken by #1256 (e2e-probe labels) -> moved to 0.24.3
second push 0.24.3 taken by #1365 (discipline-rename prose) -> moved to 0.24.4

Now 0.24.4, with 0.24.2 and 0.24.3 intact below it. The diff is still exactly the same three files and 25 insertions it was at review time — no content was dropped or re-litigated in either rebase.

One detail worth flagging for whoever merges, since git did not: only the CHANGELOG.md heading conflicts; plugin.json merges cleanly to the wrong value. A one-line "version" change auto-merges to whatever main last set, so a rebase that resolves only the marked conflict silently ships a manifest version that disagrees with the changelog entry above it. The repo's check-changelog-parity.sh --check-bump gate catches exactly that, and it passes here — but it is worth knowing the clean-looking half is the one that needs checking. Verified locally against origin/main before each push, alongside markdownlint / typos / editorconfig and a byte-level check that neither file picked up mojibake or CRLF through the conflict resolution.

If a third work-items PR lands before this merges, the same one-line bump applies.

This was generated by AI (autonomous work-loop lane).

@claude

claude Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 1m 15s —— View job


PR Review — #1340 (sync: e30e799)

  • Read changed files at current HEAD
  • Verify -Raw fix applied to Get-Content
  • Verify Python write-side encoding added
  • Review overall correctness and alignment
  • Post findings

All prior findings resolved. This PR is ready to merge.

What e30e799 fixed

Both correctness issues flagged by the previous Claude review (b907b0a) and by Codex have been addressed in this commit:

1. Get-Content -Raw — applied ✅

Permalink

Get-Content -Raw -Encoding utf8

-Raw returns a single multiline string rather than a string[]. The added inline note — "without -Raw you get a line array, not the one string the write below takes" — correctly explains why: PowerShell coerces string[] to string by joining with $OFS (space), collapsing every line break in a multi-line body.

2. Python write-side encoding — applied ✅

Permalink

open(path, 'w', encoding='utf-8')

The gotcha now explicitly states "read and write" and names open(path, 'w', encoding='utf-8') as the write-side counterpart. PYTHONUTF8=1 is correctly noted as covering both sides.

Full technical review of the final gotcha

Claim Verdict
gh transports (--json/--jq, gh api, >, --body-file) are byte-faithful ✅
Corruption: UTF-8 read as ANSI, re-encoded, written back silently (all exits 0) ✅
Em-dash U+2014 → U+00E2 U+20AC U+201D ✅
Python open() no-encoding = ANSI code page through 3.14; PEP 686 flips default in 3.15 ✅
open(path, 'rb').read().decode('utf-8') — binary mode, bytes.decode() valid ✅
open(path, 'w', encoding='utf-8') — write-side encoding ✅
PYTHONUTF8=1 covers both read and write sides ✅
PS 5.1 Get-Content defaults to ANSI; PS 6+ defaults to utf8NoBOM ✅
Get-Content -Raw returns one multiline string vs string[] ✅
PS 5.1 -Encoding utf8 prepends BOM; utf8NoBOM invalid in 5.1 ✅
[IO.File]::WriteAllText($p, $s, (New-Object Text.UTF8Encoding $false)) — UTF-8 no BOM ✅
"PowerShell 6+ has both" (utf8 BOM and utf8NoBOM) ✅

Metadata

plugin.json version is 0.24.4; CHANGELOG.md [0.24.4] heading and Documentation entry are consistent and follow the repo's Keep a Changelog conventions.

Repo guidelines

No hardcoded paths, no PII/secrets, explicit semver patch bump, Conventional Commits PR title (docs(work-items): …) — all satisfied.


No issues found. The PR is correct, complete, and aligned with the repo guidelines.

@claude

claude Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 1m 4s —— View job


Security Review — PR #1340 (head e30e799)

  • Fetch PR diff
  • Read changed files
  • Analyze for security vulnerabilities
  • Post findings

No security issues found.

This PR changes three files, all documentation or metadata:

File Change
plugins/work-items/.claude-plugin/plugin.json Semver patch bump 0.24.3 → 0.24.4
plugins/work-items/CHANGELOG.md Changelog entry for [0.24.4]
plugins/work-items/tools/work-item-tracker/adapters/github/README.md New cross-cutting gotcha about UTF-8 body-edit safety

Surfaces checked:

  • Injection (command, path, template): The new gotcha adds code snippet examples in prose: open(path, encoding='utf-8'), open(path, 'rb').read().decode('utf-8'), open(path, 'w', encoding='utf-8'), Get-Content -Raw -Encoding utf8, and [IO.File]::WriteAllText($p, $s, (New-Object Text.UTF8Encoding $false)). All are static documentation — none are executed at runtime by the plugin. The $p/$s variables in the PowerShell WriteAllText snippet are consumer-supplied variables in the ad-hoc write context the doc is advising on; there is no injection surface in a static prose example.
  • Token / secret / credential handling: None introduced or referenced.
  • GitHub Actions patterns: No workflow files changed. No pull_request_target, workflow_run, run: block script injection, permission widening, or new action references.
  • Supply-chain / dependency pins: No new dependencies, action references, or version pins added.
  • Permission changes: None.
  • File encoding integrity: The committed diff contains no BOM, no \r bytes, and no mojibake sequences — consistent with the PR body's claimed iconv/od verification. No permalink to the new content shows plain UTF-8 documentation prose.
  • External links: The single new external link (https://peps.python.org/pep-0686/) points to the Python Software Foundation's canonical PEP index — no redirects or third-party trust delegation.

The guidance added reduces data-corruption risk for consumers doing out-of-pipeline body edits; it is a net positive for data integrity with no new attack surface.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e30e799aa4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@claude

claude Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 1m 49s —— View job


PR Review — #1340 (sync: 80bc46f)

  • Read changed files at current HEAD
  • Verify the Codex "byte-faithful vs encoding-safe" finding is addressed in 80bc46f
  • Review overall correctness and alignment
  • Post findings

All prior findings resolved. This PR is ready to merge.

What 80bc46f fixed

The final Codex finding (against e30e799) was: the "byte-faithful" guarantee is false because $(cat …) strips trailing newlines and printf re-adds exactly one — the shapes normalize line endings and trailing whitespace on purpose, so "byte-for-byte" was an over-claim.

80bc46f ("scope the pipeline guarantee to encoding, not bytes") addresses this in full:

  • The gotcha heading is now "Keep body edits inside the UTF-8-safe pipeline; force UTF-8 anywhere they leave it" — the word "byte-faithful" is gone.
  • The claim is now explicitly scoped: "That is an encoding guarantee, not a byte-for-byte one".
  • The normalization behavior is named inline: "tr -d '\r' drops CRs; $(cat …) strips trailing newlines, and the printf '%s\n' puts exactly one back" — this is accurate for both code examples (lines 136–138 and 173–176), which both use printf '%s\n\n%s\n' ending in \n.

Full technical review of the final gotcha

Claim Verdict
gh transports pass encoding through untouched (no transcoding) ✅
Guarantee is encoding-safe, not byte-for-byte ✅
$(cat …) strips trailing newlines; printf adds one back ✅
Corruption: UTF-8 read as ANSI, re-encoded, written back silently (exits 0) ✅
Em-dash U+2014 → U+00E2 U+20AC U+201D ✅
Python open() no-encoding = ANSI code page through 3.14; PEP 686 flips default in 3.15 ✅
open(path, 'rb').read().decode('utf-8') — binary mode, bytes.decode() valid ✅
open(path, 'w', encoding='utf-8') — write-side encoding ✅
PYTHONUTF8=1 covers both read and write sides ✅
PS 5.1 Get-Content defaults to ANSI; PS 6+ defaults to utf8NoBOM ✅
Get-Content -Raw returns one multiline string vs string[] ✅
PS 5.1 -Encoding utf8 prepends BOM; utf8NoBOM invalid in 5.1 ✅
[IO.File]::WriteAllText($p, $s, (New-Object Text.UTF8Encoding $false)) — UTF-8 no BOM ✅
PowerShell 6+ has both utf8 (BOM) and utf8NoBOM ✅

Metadata

plugin.json version 0.24.4; CHANGELOG.md [0.24.4] entry uses the repo-local Documentation heading, matches the prior [0.24.3] format, and references #1037. Consistent.

Repo guidelines

No hardcoded paths, no PII/secrets, explicit semver patch bump, Conventional Commits PR title (docs(work-items): …) — all satisfied. Four-commit resolution history (binary-mode decode → Get-Content -Raw + Python write-side → encoding-scope correction) is clean and fully addressed.

No issues found.

@claude

claude Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 1m 45s —— View job


Security Review — PR #1340 (head 80bc46f)

  • Fetch PR diff
  • Read changed files
  • Analyze for security vulnerabilities
  • Post findings

No security issues found.

This PR changes three files, all documentation or metadata:

File Change
plugins/work-items/.claude-plugin/plugin.json Semver patch bump 0.24.3 → 0.24.4
plugins/work-items/CHANGELOG.md Changelog entry for [0.24.4]
plugins/work-items/tools/work-item-tracker/adapters/github/README.md New cross-cutting gotcha about UTF-8 body-edit safety (lines 326–346)

Surfaces checked:

  • Injection (command, path, template): The new gotcha adds code snippet examples in prose: open(path, encoding='utf-8'), open(path, 'rb').read().decode('utf-8'), open(path, 'w', encoding='utf-8'), Get-Content -Raw -Encoding utf8, and [IO.File]::WriteAllText($p, $s, (New-Object Text.UTF8Encoding $false)). All are static documentation — none are executed at runtime by the plugin. The $p/$s variables in the PowerShell WriteAllText snippet are consumer-supplied variables in the ad-hoc write context the doc is advising on; there is no injection surface in a static prose example.
  • Token / secret / credential handling: None introduced or referenced.
  • GitHub Actions patterns: No workflow files changed. No pull_request_target, workflow_run, run: block script injection, permission widening, or new action references.
  • Supply-chain / dependency pins: No new dependencies, action references, or version pins added.
  • Permission changes: None.
  • File encoding integrity: The committed diff contains no BOM, no \r bytes, and no mojibake sequences — consistent with the PR body's claimed iconv/od verification. The [README.md permalink](https://github.com/melodic-software/claude-code-plugins/blob/80bc46fd9699ccd0da7fb28dfa57d8181ae704e0/plugins/work-items/tools/work-item-tracker/adapters/github/README.md#L326) to the new content confirms plain UTF-8 documentation prose.
  • External links: The single new external link (https://peps.python.org/pep-0686/) points to the Python Software Foundation's canonical PEP index — no redirects or third-party trust delegation.

The guidance added reduces data-corruption risk for consumers doing out-of-pipeline body edits; it is a net positive for data integrity with no new attack surface.

@kyle-sexton
kyle-sexton merged commit d8be922 into main Jul 25, 2026
1 check passed
@kyle-sexton
kyle-sexton deleted the fix/1037-gh-body-utf8-decode branch July 25, 2026 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tooling: gh CLI --json/--jq body fetch + bash redirect silently mojibake-corrupts UTF-8 em-dashes on write-back (durable tracker content at risk)

1 participant