LearnNewsExamplesServices
Frontmatter
id19847
titleA Bash guard refuses gh edit --body-file - fed by an unchecked pipe
stateClosed
labels
enhancementdeveloper-experienceai
assigneesneo-opus-vega
createdAtOct 18, 2026, 12:03 AM
updatedAtOct 18, 2026, 1:38 AM
githubUrlhttps://github.com/neomjs/neo/issues/19847
authorneo-opus-vega
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtOct 18, 2026, 1:38 AM

A Bash guard refuses gh edit --body-file - fed by an unchecked pipe

Closed Backlog/active-chunk-9 enhancementdeveloper-experienceai
neo-opus-vega
neo-opus-vega commented on Oct 18, 2026, 12:03 AM

Context

A seat has twice blanked a GitHub body by piping a transform into gh … edit --body-file -:

  • 2026-10-12, neomjs/neo-stage#24 (13k chars of a folded decision): the sed failed on an unescaped / and printed nothing.
  • 2026-10-17 21:43Z, neomjs/neo-stage#170, a PR under review: the node transform failed with MODULE_NOT_FOUND, because its path came from a glob that matched another session's scratch directory. The body sat at 0 chars for 33 s and was restored from GraphQL userContentEdits.

The same seat (Vega) had recorded the lesson after the first occurrence, and discipline did not hold. The defect-note at 21:45Z promotes it as a second occurrence.

The Problem

A pipeline cannot keep the old value when its producer fails. --body-file - writes whatever arrives on stdin, and GitHub accepts an empty body for pr edit and issue edit. The producer doesn't matter (sed, node, jq). set -o pipefail alone doesn't help either: it only changes the exit code after the consumer has already written.

The Architectural Reality

  • .claude/settings.json runs two PreToolUse Bash guards: .claude/hooks/rgReplaceGuardHook.mjs (the rg -r footgun; it exports tokenizeShellCommand) and .claude/hooks/harnessIdGuardHook.mjs. Both fail open on a malformed payload.
  • The spec precedent is test/playwright/unit/hooks/rgReplaceGuardHook.spec.mjs.

The Fix

Add .claude/hooks/bodyFileGuardHook.mjs as a sibling that reuses tokenizeShellCommand, and register it in .claude/settings.json beside the rg guard.

It blocks a Bash command when a gh pr edit or gh issue edit segment reads its body from stdin (--body-file -, --body-file=-, -F -) and consumes a pipe. It allows the command if the producer is printf or echo of one variable and the command checks that variable's length or emptiness (${#V}, -n "$V", -z "$V").

The block message names the failure and the safe shape: set -o pipefail; V=$(producer) || exit 1; [ ${#V} -gt N ] || exit 1; printf '%s' "$V" | gh … edit --body-file -.

Acceptance Criteria

  • It blocks gh pr view 1 --json body --jq .body | sed s/a/b/ | gh pr edit 1 --body-file -, and the same with a node or jq producer, --body-file=-, -F -, or gh issue edit.
  • It allows the guarded variable shape above, gh pr edit 1 --body-file body.md, a heredoc body, and gh pr create … --body-file -, where an empty body loses nothing.
  • It fails open on a malformed payload, as the rg guard does.
  • test/playwright/unit/hooks/bodyFileGuardHook.spec.mjs covers each arm. Mutation: a guard that never sees the pipe lets the sed shape through and fails the spec.

Out of Scope

  • gh api -X PATCH … -f body="$V" with an unchecked variable: the same class, a second rule if it recurs.
  • Other harness families' hook systems: the defect-note reached them.

Related

  • neomjs/neo-stage#24, neomjs/neo-stage#170: the two occurrences.
  • A2A defect-note 2f129777 (2026-10-17 21:45Z).

Creation checks

  • Live latest-open sweep at 22:03Z: the latest 20 open neo issues; none equivalent. A search for "body-file" finds none.
  • A2A all-status sweep: no claim on .claude/hooks.
  • MC: the 10-12 lesson is Vega's own record; no prior decision on a hook.
  • Structure: a sibling of the existing .claude/hooks/ guards; no Agent OS placement.

Origin Session ID: 964d6ca5-1709-49ac-a7a5-2e6ca64dd031 Retrieval Hint: "gh edit body-file stdin empty body blank pipeline guard hook"

tobiu referenced in commit fbb9ec0 - "feat(hooks): a Bash guard refuses gh edit --body-file - fed by an unchecked pipe (#19847) (#19848) on Oct 18, 2026, 1:38 AM
tobiu closed this issue on Oct 18, 2026, 1:38 AM