test(scripts): capture before grep in harness-jira-test to stop SIGPIPE flakes - #1164
Conversation
harness-jira-test.sh reported 2 to 4 failures per run on an unmodified
tree, and a different set each time: triage-jira-token-in-runner,
triage-jira-email-in-sandbox, triage-jira-base-url-in-sandbox and
code-jira-email-in-sandbox. The Jira harness config was never wrong.
Every one of those assertions had the shape
jira_overlay_field "${HARNESS}" "<expr>" | grep -qF "KEY"
under the script's `set -euo pipefail`. `grep -q` exits at its first
match, so when the key is early in yq's multi-line output yq is still
writing and takes SIGPIPE; pipefail then reports the successful match as
a failed condition. Instrumented with PIPESTATUS, the JIRA_TOKEN check
returned `rc=141 pipestatus=[0]` on 6 of 8 runs — 141 is 128+13, SIGPIPE
— while the yq expression alone printed JIRA_TOKEN every time.
That explains the exact failure set. Positive greps whose match is early
in multi-line output flake; the negative *-not-in-sandbox checks never
did, because a non-matching grep reads to EOF; and the single-line
.providers[] and .openshell.profiles[] checks never did either. The race
also needs suite contention: the same pipeline passed 40 out of 40 runs
in isolation.
Add jira_overlay_has, which captures the field into a variable and greps
a here-string, and route the fourteen piped call sites through it. The
script now passes 12 consecutive runs.
Assisted-by: Claude
Signed-off-by: Wayne Sun <gsun@redhat.com>
PR Summary by QodoStabilize Jira harness assertions against SIGPIPE
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
Code Review by Qodo
1. Protected script path modified
|
|
🤖 Finished Review · ✅ Success · Started 12:56 PM UTC · Completed 1:09 PM UTC Commit: Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $3.37 |
|
Risk Assessment: moderate (2/5) DetailsSmall, single-file test script fix by a known contributor with full test coverage, modestly elevated by one protected path and the file being a recent churn hotspot with multiple authors and prior fix commits in the 90-day window. |
ReviewFindingsHigh
Low
Next steps:
|
|
Tracking issue for the flake: #1165 (test-only fix, no production impact; protected-path approval is a human call). |
Outdated: the protected-path authorization concern is addressed by the linked tracking issue and explicit human approval.
|
🤖 Finished Retro · ✅ Success · Started 1:07 PM UTC · Completed 1:19 PM UTC Commit: Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $3.72 |
Retro: PR #1164 — SIGPIPE flake fix in harness-jira-test.shOutcome: Clean workflow with zero rework. The fix was correct on the first attempt. Timeline
AssessmentReview quality: Good. The correctness sub-agent confirmed the fix is sound, and the challenger pass appropriately removed a cosmetic Rework rate: Zero. No fix agent dispatched, no code changes requested. Token cost: $3.37, elevated by a sub-agent model fallback. Four of five sub-agents (risk-assessment, style-conventions, intent-coherence, docs-currency) were configured for Autonomy readiness: Agent and human were aligned — both agreed the code was correct. The Existing issues with supporting evidence
ConclusionNo new proposals. The workflow executed cleanly, the code was correct first try, and the identified improvement areas (protected-path severity calibration, model alias resolution) are already tracked in existing issues. |
Summary
scripts/harness-jira-test.shruns underset -euo pipefail, and its positive assertions werejira_overlay_field … | grep -qF KEY.grep -qexits on the first match whileyqis still writing the rest of a multi-line result, soyqtakes SIGPIPE (rc 141) andpipefailturns the assertion false. Only the positive multi-line greps flake, which matches the observed failing set exactly (triage-jira-token-in-runner,triage-jira-email-in-sandbox,triage-jira-base-url-in-sandbox,code-jira-email-in-sandbox); the negative*-not-in-sandboxchecks read to EOF and never did. The harness files are correct.Changes
jira_overlay_has <harness> <expr> <needle>: captures the field into a variable and greps a here-string, so there is no pipe to break. The 14 piped call sites use it; the twogrep -qF <pattern> <file>sites (no pipe) are untouched.Testing
bash scripts/harness-jira-test.sh, all exit 0 (before: 2–4 failures per run, different set each time).make lint0/0.