Skip to content

fix(test): drain stdin in scheduler-wake test fixture to close a SIGPIPE flake - #1557

Closed
seonghobae wants to merge 1 commit into
mainfrom
fix/scheduler-wake-test-sigpipe-flake
Closed

fix(test): drain stdin in scheduler-wake test fixture to close a SIGPIPE flake#1557
seonghobae wants to merge 1 commit into
mainfrom
fix/scheduler-wake-test-sigpipe-flake

Conversation

@seonghobae

Copy link
Copy Markdown
Contributor

The bug

tests/test_opencode_required_verdict_regression.py::test_scheduler_wake_reuses_trusted_receipt_predicate intermittently fails with AssertionError: assert 141 == 0 (SIGPIPE) — first observed on #1519 (an unrelated Dependabot version bump) via the Hourly cadence, immutable source, NIM credential, and conflict scope required check, then reproduced locally at roughly 1/20 runs.

Root cause: the test's fake gh script's repos/ContextualWisdomLab/.github/dispatches branch never reads stdin before exiting:

elif [[ "$*" == *"repos/ContextualWisdomLab/.github/dispatches"* ]]; then
  printf 'dispatch\n' >>"$DISPATCH_CALLS"
fi

The real production pipe under test is jq -cn ... | GH_TOKEN="$app_token" gh api -X POST repos/ContextualWisdomLab/.github/dispatches --input -. When the fake gh process (the pipe's reader) exits before jq -cn (the pipe's writer) finishes writing — a timing race, not deterministic — the writer receives SIGPIPE, and under this script's set -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 fake gh's dispatches branch before it proceeds, so the pipe's reader always fully consumes the writer's output regardless of scheduling timing:

elif [[ "$*" == *"repos/ContextualWisdomLab/.github/dispatches"* ]]; then
  cat >/dev/null
  printf 'dispatch\n' >>"$DISPATCH_CALLS"
fi

Validation

  • Reproduced the flake locally before the fix: ~1/20 runs of test_scheduler_wake_reuses_trusted_receipt_predicate failed with assert 141 == 0.
  • After the fix: 60/60 clean runs of the same test.
  • PYTHONPATH=. python3 -m pytest tests -q: 2246 passed, 1 skipped, 21 subtests.
  • ruff check .: no new findings (one pre-existing, unrelated F401 in tests/test_opencode_model_pool_runner.py, confirmed present before this change via git 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

…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.
@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copy link
Copy Markdown
Contributor Author

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 (Repository.fullDatabaseId does not exist), not by repository state. To avoid leaving a valid one-line flake fix indefinitely unreachable by the normal reviewer pipeline, I am replacing this draft conversation with a fresh non-draft PR from the identical unchanged branch/head. No checks/reviews from this PR transfer; the successor must regenerate exact-head evidence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants