fix: stop stderr leakage from git probes in workflow policies#133
Conversation
Policies like require-push-before-stop, require-pr-before-stop, and
require-ci-green-before-stop run several git subcommands that are expected
to sometimes fail — e.g., probing `git rev-parse origin/<branch>` before
the branch has been pushed, or `git log origin/main..HEAD` in contexts
where the ref resolution itself is the probe. The policy code catches the
exception, but Node's `execFileSync`/`execSync` default to `stdio[2] =
'inherit'`, so git's stderr ("fatal: Needed a single revision", etc.)
leaked to the user's terminal even though the policy handled the failure
correctly.
Fix: set `stdio: ["pipe", "pipe", "pipe"]` on every exec call in
builtin-policies.ts. stderr is now captured into the error object (and
discarded) instead of bleeding through to the user. Applied uniformly
since the only supported "output" of these git probes is the returned
stdout — any message on stderr is noise.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 22 minutes and 40 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Workflow Stop policies (
require-push-before-stop,require-pr-before-stop,require-ci-green-before-stop, etc.) run several git probes that are expected to sometimes fail — e.g.,git log origin/<branch>..HEADbefore the branch has been pushed, orgit rev-parse --verify origin/<branch>to detect tracking. The policy code catches the exception cleanly, but Node'sexecFileSync/execSyncdefault tostdio[2] = "inherit", so git's own stderr (fatal: Needed a single revision,fatal: ambiguous argument, etc.) leaked to the user's terminal even though the policy handled the failure correctly.This surfaced as noise alongside every Stop-policy denial:
Fix
Set
stdio: ["pipe", "pipe", "pipe"]on everyexecFileSync/execSynccall insrc/hooks/builtin-policies.ts. stderr is now captured into the thrown error (and discarded) instead of bleeding through to the user. Applied uniformly across all 19 exec sites since the only supported "output" of these probes is the returned stdout — anything on stderr is noise.Test plan
npx tsc --noEmitpassesgit log origin/no-such-ref..HEADnow returns silently withstdio: "pipe", vs. leakingfatal: ambiguous argument ...without itfatal:preamble; only the policy's own deny message is printedGenerated with Claude Code