fix(enable): prevent wizard from exiting on non-fatal source checks (#193)#201
fix(enable): prevent wizard from exiting on non-fatal source checks (#193)#201ppillo wants to merge 1 commit intofrankbria:mainfrom
Conversation
WalkthroughThe changes introduce error-safe fallbacks for count retrieval functions in ralph_enable.sh. Both Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@ralph_enable.sh`:
- Around line 240-245: The beads_count and gh_count captures use
$(get_beads_count ... || echo "0") and $(get_github_issue_count ... || echo "0")
which double-emit "0" when the underlying functions already echo "0" and return
non-zero; change each capture to use $(get_beads_count 2>/dev/null || true) and
$(get_github_issue_count 2>/dev/null || true) so the command substitution only
returns the function output, then normalize the variable to zero with
beads_count="${beads_count:-0}" and gh_count="${gh_count:-0}" before calling
print_detection_result or using the counts elsewhere (references:
get_beads_count, get_github_issue_count, beads_count, gh_count,
print_detection_result).
| beads_count=$(get_beads_count 2>/dev/null || echo "0") | ||
| print_detection_result "beads" "$beads_count open issues" "true" | ||
| fi | ||
| if [[ "$DETECTED_GITHUB_AVAILABLE" == "true" ]]; then | ||
| local gh_count | ||
| gh_count=$(get_github_issue_count) | ||
| gh_count=$(get_github_issue_count 2>/dev/null || echo "0") |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
# First, let's check if lib/task_sources.sh exists and examine the function implementations
git ls-files | grep -E "lib/task_sources|ralph_enable"Repository: frankbria/ralph-claude-code
Length of output: 159
🏁 Script executed:
# Search for the function implementations and their behavior
rg -n "get_beads_count|get_github_issue_count" --type bashRepository: frankbria/ralph-claude-code
Length of output: 99
🏁 Script executed:
# Check the specific lines in ralph_enable.sh mentioned in the review
rg -n -A2 -B2 "beads_count=|gh_count=" ralph_enable.sh | head -80Repository: frankbria/ralph-claude-code
Length of output: 1099
🏁 Script executed:
cat -n lib/task_sources.sh | grep -A 15 "get_beads_count\|get_github_issue_count"Repository: frankbria/ralph-claude-code
Length of output: 1994
🏁 Script executed:
# Also search for the entire function definitions
rg -n "^(get_beads_count|get_github_issue_count)\(\)" -A 10 lib/task_sources.shRepository: frankbria/ralph-claude-code
Length of output: 818
Remove redundant fallback echo in count capture.
When get_beads_count() or get_github_issue_count() detects unavailable integrations (lines 116–120, 226–229 in lib/task_sources.sh), they echo "0" and return 1. The $(... || echo "0") pattern at lines 240, 245, 292, and 299 captures this "0" output, then executes the fallback echo "0" again because the function returned non-zero, resulting in multiline values (0\n0) in count variables. This corrupts the UI text in print_detection_result and option labels.
Replace each occurrence with $(... || true) followed by "${var:-0}" to capture the function's output once and only apply a fallback if empty:
Suggested fix
beads_count=$(get_beads_count 2>/dev/null || true)
+ beads_count="${beads_count:-0}"
print_detection_result "beads" "$beads_count open issues" "true"Apply the same change at lines 245, 292, and 299 for gh_count.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@ralph_enable.sh` around lines 240 - 245, The beads_count and gh_count
captures use $(get_beads_count ... || echo "0") and $(get_github_issue_count ...
|| echo "0") which double-emit "0" when the underlying functions already echo
"0" and return non-zero; change each capture to use $(get_beads_count
2>/dev/null || true) and $(get_github_issue_count 2>/dev/null || true) so the
command substitution only returns the function output, then normalize the
variable to zero with beads_count="${beads_count:-0}" and
gh_count="${gh_count:-0}" before calling print_detection_result or using the
counts elsewhere (references: get_beads_count, get_github_issue_count,
beads_count, gh_count, print_detection_result).
Summary
ralph-enablefrom exiting early underset -ewhen task source counters return non-zero.get_beads_countandget_github_issue_countin interactive flow.Test plan
ralph-enablein a project without authenticatedghand verify wizard completes.ralph-enablewith available integrations and verify counts still display.Summary by CodeRabbit
Release Notes