fix: session-distill-helper.sh jq error on grep -c zero matches#2791
fix: session-distill-helper.sh jq error on grep -c zero matches#2791marcusquinn merged 1 commit intomainfrom
Conversation
grep -c exits non-zero when no matches found, causing '|| echo 0' to append a second '0' to the captured output. The resulting '0\n0' string is not valid JSON and fails jq --argjson. Fix: replace '|| echo 0' with '|| true' to suppress the non-zero exit without appending duplicate output, then guard with an empty-check. Fixes #2790
Summary of ChangesHello, 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 subtle bug in the Highlights
Changelog
Activity
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
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
WalkthroughFixed a shell script bug where Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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: Tue Mar 3 20:07:44 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
|
There was a problem hiding this comment.
Code Review
This pull request correctly addresses a bug where grep -c with zero matches could produce invalid output. The use of || true combined with a check for an empty variable is a robust way to handle the non-zero exit code from grep while ensuring a valid number is always produced, preventing downstream jq errors. The changes are sound and I have no further comments.



Summary
grep -cexits non-zero when zero matches are found, causing|| echo "0"to append a second0to the captured output — producing"0\n0"which is not valid JSON and failsjq --argjson|| echo "0"with|| trueon both affected lines, then added an empty-string guard to default to0error_fixes(line 68) andcompleted_tasks(line 73) inanalyze_session()Verification
ShellCheck passes (only pre-existing SC1091 info-level finding for sourced script).
Closes #2790
Summary by CodeRabbit