Skip to content

Comments

t1071: Fix pulse Phase 3b2 crash on mergedAt:null#1554

Closed
marcusquinn wants to merge 1 commit intomainfrom
feature/t1071
Closed

t1071: Fix pulse Phase 3b2 crash on mergedAt:null#1554
marcusquinn wants to merge 1 commit intomainfrom
feature/t1071

Conversation

@marcusquinn
Copy link
Owner

@marcusquinn marcusquinn commented Feb 17, 2026

Summary

  • Fix crash in supervisor pulse Phase 3b2 when gh pr view returns "mergedAt":null for unmerged PRs
  • The grep pipeline extracting mergedAt failed with exit 1 (no match), which propagated through set -o pipefail and triggered set -e, crashing the entire pulse cycle
  • Added || true to the pipeline so an empty pr_merged_at is returned gracefully — downstream code already handles empty values (used only in log messages and proof-log evidence)

Root Cause

pulse.sh:591 used grep -o '"mergedAt":"[^"]*"' to extract the merge timestamp. When GitHub returns "mergedAt":null (unquoted null, not a string), the regex has no match, grep exits 1, pipefail propagates it, and set -e aborts the function.

Verification

Tested all three scenarios under set -eo pipefail:

  • mergedAt:null (OPEN/CLOSED PR) — returns empty string, no crash
  • mergedAt:"2025-..." (MERGED PR) — returns timestamp correctly
  • ShellCheck passes clean

Ref #1552

Summary by CodeRabbit

  • Bug Fixes
    • Improved system reliability by fixing a potential script failure when certain pull request metadata fields are unavailable, ensuring more stable operation.

gh pr view returns "mergedAt":null for unmerged PRs. The grep pipeline
on line 591 failed with exit 1 (no match), which propagated through
set -o pipefail and triggered set -e, crashing the entire pulse cycle.

Added || true to the pipeline so an empty pr_merged_at is returned
instead of a fatal error. Downstream code already handles empty values
gracefully (used only in log messages and proof-log evidence).
@gemini-code-assist
Copy link

Summary of Changes

Hello @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 enhances the robustness of the supervisor pulse script by preventing crashes caused by unexpected API responses. Specifically, it ensures that the script can gracefully handle cases where a pull request's mergedAt field is null, avoiding script termination and improving overall stability.

Highlights

  • Crash Fix: Resolved a crash in the supervisor pulse Phase 3b2 that occurred when gh pr view returned "mergedAt":null for unmerged pull requests.
  • Robustness Improvement: Prevented the grep pipeline from failing with an exit 1 status (due to no match) by adding || true, ensuring the script continues gracefully even when mergedAt is null.
  • Error Handling: Addressed an issue where set -o pipefail and set -e propagated the grep failure, causing the entire pulse cycle to crash.
Changelog
  • .agents/scripts/supervisor/pulse.sh
    • Modified the grep command used to extract mergedAt to include || true, preventing script failure when no match is found.
Activity
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 17, 2026

No actionable comments were generated in the recent review. 🎉


Walkthrough

A single-line change to .agents/scripts/supervisor/pulse.sh adds error handling to the mergedAt field extraction by appending || true, preventing script failure when the field is absent from PR JSON data.

Changes

Cohort / File(s) Summary
Pulse Script Robustness
.agents/scripts/supervisor/pulse.sh
Added `

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related issues

Possibly related PRs

Poem

🔧 A single pipe, a truthful call,
When mergedAt fields decide to fall,
No crash, no break, the script holds strong,
DevOps harmony all day long! ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Merge Conflict Detection ⚠️ Warning ⚠️ Unable to check for merge conflicts: Failed to fetch base branch: From https://github.com/marcusquinn/aidevops
! [rejected] main -> main (non-fast-forward)
+ e764323...04b69f1 main -> origin/main (forced update)
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and specifically describes the main fix: addressing a crash in pulse Phase 3b2 when mergedAt is null, which matches the core change in the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/t1071
⚔️ Resolve merge conflicts (beta)
  • Auto-commit resolved conflicts to branch feature/t1071
  • Create stacked PR with resolved conflicts
  • Post resolved changes as copyable diffs in a comment

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.

Copy link

@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 correctly fixes a crash caused by grep failing to find a mergedAt value. The addition of || true is a valid minimal fix. My review includes a suggestion to further improve the robustness of this code by using jq for JSON parsing, which would prevent this class of error entirely and simplify the code.

Comment on lines 590 to +591
pr_state=$(echo "$pr_json" | grep -o '"state":"[^"]*"' | cut -d'"' -f4)
pr_merged_at=$(echo "$pr_json" | grep -o '"mergedAt":"[^"]*"' | cut -d'"' -f4)
pr_merged_at=$(echo "$pr_json" | grep -o '"mergedAt":"[^"]*"' | cut -d'"' -f4 || true)

Choose a reason for hiding this comment

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

medium

While adding || true effectively prevents the script from crashing, using grep and cut to parse JSON is inherently fragile. A more robust and maintainable approach is to use a dedicated JSON parser like jq, which is also mentioned as an alternative in the task description for t1071.

Using jq would make the code cleaner and safer, and would also address the same potential fragility in the pr_state extraction on the preceding line.

Suggested change
pr_state=$(echo "$pr_json" | grep -o '"state":"[^"]*"' | cut -d'"' -f4)
pr_merged_at=$(echo "$pr_json" | grep -o '"mergedAt":"[^"]*"' | cut -d'"' -f4)
pr_merged_at=$(echo "$pr_json" | grep -o '"mergedAt":"[^"]*"' | cut -d'"' -f4 || true)
pr_state=$(echo "$pr_json" | jq -r '.state')
pr_merged_at=$(echo "$pr_json" | jq -r '.mergedAt // empty')

@marcusquinn
Copy link
Owner Author

Superseded by PR #1555 which was merged. Closing stale duplicate.

@marcusquinn marcusquinn deleted the feature/t1071 branch February 21, 2026 01:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant