Repository navigation
fix: propagate ripgrep failures from glob - #187
Conversation
pdettori
left a comment
There was a problem hiding this comment.
Thanks for the clean, well-scoped fix and for the detailed write-up in the PR body — the PIPESTATUS[0] approach is the right one and matches the prescription in #186.
Two things verified in the process, both good news:
- The bashism is safe.
bash -cis confirmed on all three transports:exec.ts:15(kubectl),persistent-exec.ts:10(barebash), and the Go remote worker (perremote-worker/DESIGN.md). globreally is the only op piping tohead, which closes the "scope note" question at the end of #186.
CI is fully green (all 10 checks).
Blocking issue: the guard rejects rg's exit 1, which means "no matches" — not a failure. Verified against ripgrep: -g '*.ts' (match) exits 0, -g '*.zzz' (no match) exits 1, -g '[' (malformed) exits 2. The shell guard propagates the 1 (producer_rc=1 -> shell_rc=1), and the new JS check then throws. So glob("*.go", ...) in a tree with no Go files now throws glob failed in pod instead of returning [] — a routine case, and a regression against main.
This package already encodes the correct contract in grep-tool.ts:44-50:
if (r.exitCode !== 0 && r.exitCode !== 1) { ... }
// rg exits 1 with no output when there are no matches.Importantly, tolerating 1 does not reopen #186 — the malformed-pattern case that issue targets is exit 2, which still rejects. So the fix stays intact.
Details inline, plus two test suggestions that would have caught this.
|
Addressed the review feedback in commit
Validation: |
|
@mikemikimike thank you for promptly addressing the review comments. There were other changes in main, so a rebase is now needed - thanks! |
|
Addressed all four review findings in the current head
The current branch also contains the corresponding malformed-pattern and no-match regression cases. I verified the source and tests against the PR head; local Vitest execution was blocked by pnpm's build-script approval policy for esbuild/protobufjs, not by a test failure. |
|
thank you @mikemikimike , but there are still conflicts that need to be resolved in the file operations.ts |
Signed-off-by: mikemikimike <[email protected]>
Signed-off-by: mikemikimike <[email protected]>
efba9ea to
30901f9
Compare
|
Rebased onto current main and resolved the operations.ts conflict while preserving both upstream truncation protection and this PR's PIPESTATUS handling. Empty rg results remain valid (exit 1); malformed patterns still fail. New head: 30901f9. |
|
Fixed in 30901f9. The current guard allows rg exit 1 for no matches, while exit 2 still fails. CI was green before the rebase and the PR is now mergeable. |
rossoctl#187 (propagate ripgrep failures from glob) merged to main while this branch was in review, touching the same `createPodFindOps.glob`. The two changes are complementary and both are kept. rossoctl#187 adds a shell guard so `rg`'s own status survives the pipe to `head`, which would otherwise mask it: rc=${PIPESTATUS[0]}; [ "$rc" = 0 ] || [ "$rc" = 1 ] || [ "$rc" = 141 ] || exit "$rc" plus the matching `r.exitCode !== 1` tolerance, since rg exits 1 for "no matches". That is about the SEARCH failing. This branch splits truncation into its own `truncated` flag, because a cap trip is a property of the seam and can happen while rg is perfectly happy — reporting it as "rg exited N" blames the wrong component. Resolution keeps rossoctl#187's exec command verbatim and checks `truncated` first, then the null exit code, then rossoctl#187's `!== 0 && !== 1` guard. A naive resolution that took this branch's side would have silently dropped rossoctl#187's `!== 1` tolerance, reintroducing the "no matches reads as an error" bug it fixed. Verified the two compose in the pod, not just on paper: `glob` runs over the persistent channel, so the merged command is rossoctl#187's guard nested inside this branch's `{ … } | head -c <cap+1> | base64` wrapper. Inside the brace group `${PIPESTATUS[0]}` still resolves to the inner `rg | head -n` pipeline, and the group's own status becomes the outer `PIPESTATUS[0]`. Live gate 7/7 on the merged tree, with Claim 4 returning ["top.ts","src/keep.ts"] — the result SMOKE.md documents. make typecheck EXIT 0; k8s-sandbox 129 passed / 11 skipped; harness 226 passed / 3 skipped. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
Related issue
Closes #186.
Background
The
globoperation pipes ripgrep intoheadwithout preserving the producer status. Because the shell reports the last pipeline command, an invalid ripgrep pattern can return an empty result with exit code 0, hiding a real search failure.Changes
rg's status with BashPIPESTATUS[0].141status fromheadclosing a full pipe as success.Compatibility
Successful searches and normal limit truncation remain unchanged. The command runs through the existing
bash -ckubectl transport, and only genuine ripgrep failures now reject.Validation
git diff --check— passed.pnpm install --frozen-lockfile— blocked by WindowsEPERMwhile copying packages from the pnpm store.--child-concurrency=1 --network-concurrency=1— sameEPERMclass of failure.Known limitation
The full repository test, lint, typecheck, and build commands were not run because the required pnpm workspace dependencies could not be installed in this Windows environment. CI provides the authoritative validation once the fork workflow is approved.