test(scripts): capture before grep in harness-jira-test to stop SIGPIPE flakes - #1164
test(scripts): capture before grep in harness-jira-test to stop SIGPIPE flakes#1164waynesun09 wants to merge 1 commit into
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
|
| jira_overlay_has() { | ||
| local out | ||
| out="$(jira_overlay_field "$1" "$2")" | ||
| grep -qF "$3" <<< "${out}" | ||
| } |
There was a problem hiding this comment.
1. Protected script path modified 📜 Skill insight § Compliance
The PR modifies scripts/harness-jira-test.sh, which is under the protected scripts/ governance/infrastructure path. This requires human review and must not be auto-approved; the PR description does not provide a linked issue or explicit authorization for the protected-path change.
Agent Prompt
## Issue description
This PR modifies a file under the protected `scripts/` path, which requires explicit human review and authorization.
## Issue Context
The compliance rule requires a finding for protected-path changes and treats changes without a linked issue or explanation as high severity.
## Fix Focus Areas
- scripts/harness-jira-test.sh[37-47]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
🤖 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). |
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.