GH#17809: fallback to jobs API in extract_failure_signature when --log-failed is empty#17838
Conversation
…led is empty
When gh run view --log-failed returns empty output (logs expired, rate-limited,
or run still in progress), the miner falls back to the jobs API to get the first
failed job's logs directly. This avoids the unhelpful 'no_failed_log_output'
signature that produces vague systemic-failure clusters.
Fallback path:
1. GET /actions/runs/{run_id}/jobs — find first job with conclusion=failure
2. GET /actions/jobs/{job_id}/logs — get that job's log output
3. Extract error signature from logs as normal
Resolves #17809
|
Caution Review failedPull request was closed or merged during review WalkthroughUpdated metadata tracking in simplification-state.json for three shell scripts reflecting recent passes. Enhanced gh-failure-miner-helper.sh with fallback logic to query GitHub Actions jobs API when initial log retrieval returns empty results. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Completion Summary
|
🔍 Code Quality Report�[0;35m[MONITOR]�[0m Code Review Monitoring Report SonarCloud: 0 bugs, 0 vulnerabilities, 650 code smells Wed Apr 8 07:43:45 UTC 2026: Code review monitoring started 📈 Current Quality Metrics
Generated on: Wed Apr 8 07:43:48 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
Up to standards ✅🟢 Issues
|
|
There was a problem hiding this comment.
Code Review
This pull request updates the simplification state configuration and enhances the gh-failure-miner-helper.sh script with a fallback mechanism to retrieve logs via the GitHub API when the standard command fails. Feedback was provided to improve the robustness of the jq query used to identify failed jobs and to ensure error visibility by not suppressing stderr.
| failed_job_id=$(gh api "repos/${repo_slug}/actions/runs/${run_id}/jobs" \ | ||
| --jq '[.jobs[] | select(.conclusion == "failure")] | first | .id // empty' 2>/dev/null || true) |
There was a problem hiding this comment.
The current jq query can result in an error if no failed jobs are found. When [.jobs[] | select(.conclusion == "failure")] produces an empty array, first returns null. The subsequent pipe to .id (null | .id) causes jq to error. Additionally, avoid suppressing stderr with 2>/dev/null as it can hide syntax or system errors. Use the fallback operator // to provide a default value and || true to prevent script exit if the command fails, ensuring diagnostic information remains visible.
| failed_job_id=$(gh api "repos/${repo_slug}/actions/runs/${run_id}/jobs" \ | |
| --jq '[.jobs[] | select(.conclusion == "failure")] | first | .id // empty' 2>/dev/null || true) | |
| failed_job_id=$(gh api "repos/${repo_slug}/actions/runs/${run_id}/jobs" \ | |
| --jq '[.jobs[] | select(.conclusion == "failure") | .id] | first // empty' || true) |
References
- In jq, use the fallback operator // to provide a default value for expressions that might result in null.
- Avoid suppressing stderr with 2>/dev/null on commands like jq to ensure diagnostic information remains visible.
marcusquinn
left a comment
There was a problem hiding this comment.
Auto-approved by pulse — collaborator PR (author: @alex-solovyev). All pre-merge checks passed.
Completion Summary
Merged via PR #17838 to main.
|
MergedResolves #17809 aidevops.sh v3.6.172 plugin for OpenCode v1.4.0 with claude-sonnet-4-6 spent 19m and 15,165 tokens on this as a headless worker. |



Summary
Fixes the
no_failed_log_outputerror signature ingh-failure-miner-helper.shby adding a fallback to the GitHub jobs API whengh run view --log-failedreturns empty output.Root Cause
extract_failure_signature()callsgh run view --log-failedto get the error text from a failed CI run. This returns empty when:When empty, the function returned the literal string
no_failed_log_outputas the signature. This caused the failure miner to cluster all such events under a single vague signature, producing unhelpful systemic-failure issues (like #17809 itself) that don't identify the actual error.Fix
Added a two-step fallback inside
extract_failure_signature():GET /actions/runs/{run_id}/jobs— find the first job withconclusion=failureGET /actions/jobs/{job_id}/logs— get that job's log output directlyBoth API calls are wrapped in
2>/dev/null || trueso failures are non-fatal. If the fallback also returns empty, the function still returnsno_failed_log_outputas before.Files Changed
.agents/scripts/gh-failure-miner-helper.sh—extract_failure_signature()function (lines 164-193)Runtime Testing
|| trueResolves #17809
aidevops.sh v3.6.171 plugin for OpenCode v1.4.0 with claude-sonnet-4-6 spent 5m and 9,965 tokens on this as a headless worker.
Summary by CodeRabbit