Skip to content

GH#17809: fallback to jobs API in extract_failure_signature when --log-failed is empty#17838

Merged
marcusquinn merged 2 commits intomainfrom
bugfix/17809-no-failed-log-output-fallback
Apr 8, 2026
Merged

GH#17809: fallback to jobs API in extract_failure_signature when --log-failed is empty#17838
marcusquinn merged 2 commits intomainfrom
bugfix/17809-no-failed-log-output-fallback

Conversation

@alex-solovyev
Copy link
Copy Markdown
Collaborator

@alex-solovyev alex-solovyev commented Apr 8, 2026

Summary

Fixes the no_failed_log_output error signature in gh-failure-miner-helper.sh by adding a fallback to the GitHub jobs API when gh run view --log-failed returns empty output.

Root Cause

extract_failure_signature() calls gh run view --log-failed to get the error text from a failed CI run. This returns empty when:

  • Run logs have expired (GitHub retains logs for 90 days, but the miner may run after expiry)
  • The run is still in progress when the miner fires
  • API rate limiting

When empty, the function returned the literal string no_failed_log_output as 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():

  1. GET /actions/runs/{run_id}/jobs — find the first job with conclusion=failure
  2. GET /actions/jobs/{job_id}/logs — get that job's log output directly

Both API calls are wrapped in 2>/dev/null || true so failures are non-fatal. If the fallback also returns empty, the function still returns no_failed_log_output as before.

Files Changed

  • EDIT: .agents/scripts/gh-failure-miner-helper.shextract_failure_signature() function (lines 164-193)

Runtime Testing

  • Risk: Low — non-fatal fallback path, both API calls wrapped in || true
  • Testing: ShellCheck zero violations on modified file; logic verified against GitHub Actions API docs

Resolves #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

  • Bug Fixes
    • Enhanced error logging recovery in CI processes with improved fallback mechanisms for retrieving failure information when standard queries are unsuccessful.

…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
@alex-solovyev alex-solovyev added bug Auto-created from TODO.md tag origin:worker Created from worker session labels Apr 8, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 8, 2026

Caution

Review failed

Pull request was closed or merged during review

Walkthrough

Updated 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

Cohort / File(s) Summary
Metadata Tracking
.agents/configs/simplification-state.json
Updated per-file tracking metadata (hashes, timestamps, pass counts) for .agents/scripts/headless-runtime-helper.sh, .agents/scripts/pulse-wrapper.sh, and aidevops.sh reflecting recent validation passes.
Log Retrieval Robustness
.agents/scripts/gh-failure-miner-helper.sh
Enhanced extract_failure_signature() function with fallback mechanism: when gh run view --log-failed returns empty logs, script now queries GitHub Actions jobs API to find the first failed job and retrieves its logs via gh api endpoint; only returns no_failed_log_output after both methods exhaust.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🚀 When logs fall silent, courage speaks,
A fallback guard through GitHub's peaks,
API cascades where empties dwell,
No signature lost—we'll always tell. 🔍

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main change: adding a fallback to the GitHub Jobs API in extract_failure_signature when --log-failed returns empty, directly addressing issue GH#17809.
Linked Issues check ✅ Passed The PR fully implements the fix proposed in #17809: adding a fallback to the Jobs API when gh run view --log-failed is empty, preventing clustering of unrelated failures under the no_failed_log_output signature.
Out of Scope Changes check ✅ Passed All changes are directly scoped to resolving #17809; the metadata updates in simplification-state.json reflect testing passes and are expected artifacts of the CI process.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bugfix/17809-no-failed-log-output-fallback

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 and usage tips.

@alex-solovyev
Copy link
Copy Markdown
Collaborator Author

Completion Summary

  • What: Added fallback to GitHub jobs API in extract_failure_signature() when --log-failed returns empty output
  • Issue: Systemic CI failure: Complexity Analysis (2 events) #17809
  • Files changed: .agents/scripts/gh-failure-miner-helper.sh
  • Testing: ShellCheck zero violations; logic verified against GitHub Actions API docs
  • Key decisions: Both API calls wrapped in || true so fallback is non-fatal; if jobs API also fails, function still returns no_failed_log_output as before

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 2026

🔍 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
Wed Apr 8 07:43:46 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 650

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 650
  • VULNERABILITIES: 0

Generated on: Wed Apr 8 07:43:48 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@codacy-production
Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

TIP This summary will be updated as you push new changes. Give us feedback

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 8, 2026

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +174 to +175
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)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
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
  1. In jq, use the fallback operator // to provide a default value for expressions that might result in null.
  2. Avoid suppressing stderr with 2>/dev/null on commands like jq to ensure diagnostic information remains visible.

Copy link
Copy Markdown
Owner

@marcusquinn marcusquinn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto-approved by pulse — collaborator PR (author: @alex-solovyev). All pre-merge checks passed.

@marcusquinn marcusquinn merged commit 60b9bb7 into main Apr 8, 2026
47 of 48 checks passed
@marcusquinn
Copy link
Copy Markdown
Owner

Completion Summary

  • What: Added fallback to GitHub jobs API in extract_failure_signature() when --log-failed returns empty output
  • Issue: Systemic CI failure: Complexity Analysis (2 events) #17809
  • Files changed: .agents/scripts/gh-failure-miner-helper.sh
  • Testing: ShellCheck zero violations; logic verified against GitHub Actions API docs
  • Key decisions: Both API calls wrapped in || true so fallback is non-fatal; if jobs API also fails, function still returns no_failed_log_output as before

Merged via PR #17838 to main.
Merged by deterministic merge pass (pulse-wrapper.sh).

aidevops.sh v3.6.171 spent 7m on this as a headless bash routine.

@marcusquinn marcusquinn deleted the bugfix/17809-no-failed-log-output-fallback branch April 8, 2026 07:50
@alex-solovyev
Copy link
Copy Markdown
Collaborator Author

Merged

Resolves #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.

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

Labels

bug Auto-created from TODO.md tag origin:worker Created from worker session

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Systemic CI failure: Complexity Analysis (2 events)

2 participants