fix(test): drain stdin in scheduler-wake test fixture to close a SIGPIPE flake - #1557
fix(test): drain stdin in scheduler-wake test fixture to close a SIGPIPE flake#1557seonghobae wants to merge 1 commit into
Conversation
…IPE flake test_scheduler_wake_reuses_trusted_receipt_predicate's fake gh never read stdin on its dispatches branch, racing the real production pipe (jq -cn ... | gh api -X POST .../dispatches --input -) -- an early-exiting non- stdin-reading downstream reader can SIGPIPE the upstream writer depending on process-scheduling timing. Reproduced locally (~1/20 runs); confirmed test-harness-only, not a production bug. Fixed by draining stdin (cat >/dev/null) before the branch proceeds; 60/60 clean runs after the fix.
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks 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 |
|
The source fix is current-main, mergeable, test-only, and locally verified, but this PR is still Draft. The connected Ready-for-review mutation is currently broken by a connector GraphQL schema error ( |
The bug
tests/test_opencode_required_verdict_regression.py::test_scheduler_wake_reuses_trusted_receipt_predicateintermittently fails withAssertionError: assert 141 == 0(SIGPIPE) — first observed on#1519(an unrelated Dependabot version bump) via theHourly cadence, immutable source, NIM credential, and conflict scoperequired check, then reproduced locally at roughly 1/20 runs.Root cause: the test's fake
ghscript'srepos/ContextualWisdomLab/.github/dispatchesbranch never reads stdin before exiting:The real production pipe under test is
jq -cn ... | GH_TOKEN="$app_token" gh api -X POST repos/ContextualWisdomLab/.github/dispatches --input -. When the fakeghprocess (the pipe's reader) exits beforejq -cn(the pipe's writer) finishes writing — a timing race, not deterministic — the writer receivesSIGPIPE, and under this script'sset -euo pipefail, that propagates as the observed exit code 141.Confirmed test-harness-only, not a production bug: the real
gh api -X POST ... --input -does read and use its stdin, so it wouldn't exit early and trigger this race outside the test.The fix
Drain stdin (
cat >/dev/null) in the fakegh'sdispatchesbranch before it proceeds, so the pipe's reader always fully consumes the writer's output regardless of scheduling timing:Validation
test_scheduler_wake_reuses_trusted_receipt_predicatefailed withassert 141 == 0.PYTHONPATH=. python3 -m pytest tests -q: 2246 passed, 1 skipped, 21 subtests.ruff check .: no new findings (one pre-existing, unrelatedF401intests/test_opencode_model_pool_runner.py, confirmed present before this change viagit stash).interrogate -c pyproject.toml .: 100.0%.git diff --check: clean.Scope
Test-only change (one added line,
cat >/dev/null), no production code touched.Generated by Claude Code