Repository navigation
Description
Problem
createPodGlobOps's glob (packages/k8s-sandbox/src/operations.ts:137) runs:
cd <cwd> && rg --files --hidden <globs> | head -n <limit>
Without pipefail, bash reports the last command's status, so head's 0 masks any rg failure. A malformed glob (rg exit 2) therefore surfaces to the model as an empty file list — "the search errored" reads as "no matches".
#184 added an exitCode check to glob (it previously checked nothing, and on a truncated exec could hand the model a partial list containing [output truncated] as a bogus path entry). That check fully closes the truncation half, because exitCode === null is set by our own JS wrapper and is unaffected by shell pipe semantics. It does not close the rg-failure half, because the non-zero branch can never fire while the pipeline masks the status.
Why pipefail is the wrong fix
Verified empirically:
no pipefail, failing producer → exit 0 # rg failure masked (today's bug)
with pipefail, failing producer → exit 1 # visible
with pipefail, head hits its limit → exit 141 # SIGPIPE — the ROUTINE case
head -n <limit> closing the pipe early is the expected path whenever a tree has more matches than limit. Under pipefail that becomes exit 141, so every normal limit-hit would start throwing. Adding pipefail trades a narrow silent-failure for a broad false-failure.
The fix that does work
${PIPESTATUS[0]} carries the producer's real status without pipefail:
no pipefail, failing producer → PIPESTATUS[0] = 1
So the command can surface rg's status while still tolerating the expected SIGPIPE:
cd <cwd> && rg --files --hidden <globs> | head -n <limit>
rc=${PIPESTATUS[0]}; [ "$rc" = 0 ] || [ "$rc" = 141 ] || exit "$rc"glob's existing non-zero check then catches genuine rg failures, and 141 (head closed the pipe) stays a success.
Scope note
Reachability of the truncation half was bounded by head -n <limit> needing a large limit in a big tree; this half needs only a malformed pattern, so it is easier to hit but less harmful — a wrong empty result rather than a corrupt one. Pre-existing, not introduced by #184.
Worth checking whether any other op in operations.ts pipes to head and inherits the same masking; glob was the only one flagged in review, but the check was by inspection rather than exhaustive.
Refs
Found addressing review on #184 · sibling residuals #180, #181, #182, #185 · epic #89.
Activity
mikemikimike commentedon Aug 29, 2026
Implemented and opened PR #187 to preserve the ripgrep producer status in the
globpipeline, tolerate the expected141head truncation status, and reject genuine ripgrep failures. Added a focused regression test for the failure path.git diff --checkpassed. Local pnpm validation was blocked twice by WindowsEPERMwhile importing packages from the pnpm store, so Vitest/typecheck could not start. The PR CI and security-scan runs were created but require repository-admin approval for fork workflows (action_required); DCO passed.