fix: use gh pr update-branch CLI instead of raw API with empty sha#2113
fix: use gh pr update-branch CLI instead of raw API with empty sha#2113marcusquinn merged 3 commits intomainfrom
Conversation
Summary of ChangesHello @marcusquinn, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical issue where GitHub PR branch updates were failing due to an incorrect API call. By switching to the more robust Highlights
Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
Caution Review failedThe pull request is closed. WalkthroughThis PR enhances supervisor script instrumentation and control flow. It migrates GitHub API calls to CLI commands in ai-lifecycle.sh, adds diagnostic logging for state transitions, and introduces conditional gating in pulse.sh to respect AI-driven lifecycle handling when enabled. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
✨ Finishing Touches
🧪 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 |
🔍 Code Quality Report�[0;35m[MONITOR]�[0m Code Review Monitoring Report �[0;34m[INFO]�[0m Latest Quality Status: �[0;34m[INFO]�[0m Recent monitoring activity: 📈 Current Quality Metrics
Generated on: Sat Feb 21 16:57:20 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
|
There was a problem hiding this comment.
Code Review
This pull request correctly replaces the raw GitHub API call for updating a branch with the more robust gh pr update-branch CLI command, resolving the 422 errors. The added logging in ai-lifecycle.sh and the guard for the legacy stale PR recovery logic in pulse.sh are also good improvements for observability and correctness.
I've found one minor bug in the new line-counting logic for logging eligible tasks and have left a suggestion to fix it, which also aligns with repository rules regarding set -e and || true.
| local repos_with_changes="" | ||
|
|
||
| local total_eligible=0 | ||
| total_eligible=$(printf '%s\n' "$eligible_tasks" | grep -c '.' || echo "0") |
There was a problem hiding this comment.
This line-counting logic is buggy when $eligible_tasks is empty. The combination of grep -c's output on no match and the || echo "0" guard results in $total_eligible being assigned a multi-line value (0\n0), which will cause problems in logs or arithmetic operations.
A more robust way to count lines in a variable is to use a here-string with grep and guard with || true, which correctly handles the empty case by returning 0.
| total_eligible=$(printf '%s\n' "$eligible_tasks" | grep -c '.' || echo "0") | |
| total_eligible=$(grep -c . <<< "$eligible_tasks" || true) |
References
- The style guide (line 13) requires using
|| trueto guard commands that may fail underset -e, such asgrep. The current implementation uses|| echo "0", which causes incorrect behavior whengrepfinds no matches. (link) - In shell scripts with 'set -e' enabled, use '|| true' to prevent the script from exiting when a command like 'grep' fails (e.g., no matches found). This ensures script continuity without suppressing error output.



The raw API call
gh api repos/.../update-branch -f expected_head_sha=""was passing an empty sha, causing 422 errors. Switch togh pr update-branchwhich handles sha correctly.Summary by CodeRabbit