Copilot repo hook test can fail with BrokenPipe when RTK is absent

Open Beginner friendly
#5,172 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
85/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust, shell
Domain
testing

Research direction

Read tests/copilot_repo_hook_test.rs, especially the fixture around lines 28-55, alongside .github/hooks/rtk-rewrite.json. Run the provided reproduction script to force the empty-PATH ordering. Change only the empty-PATH test to use null stdin and keep the piped payload for the installed-RTK case; done when the test passes without a broken pipe.

Written by the indexing model from the issue text.

Description

What happened

hook_is_silent_and_succeeds_without_rtk was the sole failure in two full Linux test runs based on develop at 3ab08bec. Both runs reported 5,423 passes and eight skips. The only local change was in the Cargo formatter. The hook and its integration test match upstream.

thread 'hook_is_silent_and_succeeds_without_rtk' panicked at tests/copilot_repo_hook_test.rs:45:10:
write payload: Os { code: 32, kind: BrokenPipe, message: "Broken pipe" }

With an empty PATH, the shell command exits 0 before reading stdin. The fixture assumes the test process always writes first.

Reproduction

This forces the failing order against the real hook. Run it from the checkout root.

import json, os, subprocess, tempfile
from pathlib import Path

hook = json.loads(Path(".github/hooks/rtk-rewrite.json").read_text())["hooks"]["PreToolUse"][0]["bash"]
with tempfile.TemporaryDirectory() as empty:
    with subprocess.Popen(
        ["/bin/sh", "-c", hook], env={"PATH": empty},
        stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
    ) as child:
        assert child.wait() == 0
        assert child.stdout.read() == child.stderr.read() == b""
        os.write(child.stdin.fileno(), b'{"tool_name":"run_in_terminal","tool_input":{"command":"git status"}}')

With stdin connected to /dev/null, the empty-PATH case exited 0 silently ten times. The installed-RTK case still consumed the original payload and returned rtk git status in all ten runs.

Would a fixture-only PR be welcome? I would give the empty-PATH test null stdin and keep the existing piped payload and assertions for the installed-RTK test.

Dominant language
Rust
Stars
86.4k
Forks
5.5k
Avg merge
7d 6h
Merged PRs (30d)
48

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rtk-ai/rtk

All issues in rtk-ai/rtk

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.