Skip to content

fix(enable): prevent wizard from exiting on non-fatal source checks (#193)#201

Open
ppillo wants to merge 1 commit intofrankbria:mainfrom
ppillo:fix/193-ralph-status-not-configured-no-progress
Open

fix(enable): prevent wizard from exiting on non-fatal source checks (#193)#201
ppillo wants to merge 1 commit intofrankbria:mainfrom
ppillo:fix/193-ralph-status-not-configured-no-progress

Conversation

@ppillo
Copy link

@ppillo ppillo commented Feb 27, 2026

Summary

  • Prevents ralph-enable from exiting early under set -e when task source counters return non-zero.
  • Adds safe fallbacks for get_beads_count and get_github_issue_count in interactive flow.
  • Keeps the setup wizard running and defaults counts to 0 when those integrations are unavailable.

Test plan

  • Run ralph-enable in a project without authenticated gh and verify wizard completes.
  • Run ralph-enable with available integrations and verify counts still display.

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Improved error handling for data retrieval operations by implementing fallback mechanisms that default to zero values when retrieval fails, preventing system failures during environment detection and task source selection phases.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 27, 2026

Walkthrough

The changes introduce error-safe fallbacks for count retrieval functions in ralph_enable.sh. Both get_beads_count and get_github_issue_count are now wrapped with fallback patterns that default to "0" when they fail. The same defensive pattern is applied in both the environment detection phase and the task source selection phase.

Changes

Cohort / File(s) Summary
Error-safe fallbacks for count retrieval
ralph_enable.sh
Applied defensive fallback patterns to beads_count and gh_count variable assignments using $(command 2>/dev/null || echo "0") syntax in two locations: environment detection and task source selection phases.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Poem

🐰 When functions stumble and errors abound,
We catch them gently without a sound,
A zero awaits as our safety net bright,
Fallbacks and grace keep the script running right! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main change: adding error-safe fallbacks to prevent the wizard from exiting on non-fatal source count checks.
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 unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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).

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6ff27b4 and 2f64c45.

📒 Files selected for processing (1)
  • ralph_enable.sh

Comment on lines +240 to +245
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")
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 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 bash

Repository: 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 -80

Repository: 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.sh

Repository: 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).

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