fix: resolve recovery boot dataset mountpoint - #36
Conversation
📝 WalkthroughWalkthrough
ChangesPassword recovery
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
✨ Simplify code
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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@scripts/menu_recovery.sh`:
- Around line 50-54: Update the config discovery flow using
config_candidate_count, config_symlink_found, and config_dir to fail closed when
traversal encounters any error. Track the validated, resolved in-root directory
selected during scanning instead of overwriting config_dir with each raw
candidate, and only delete credentials after a complete scan confirms exactly
one valid directory.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 80deae1a-8a0b-4a4a-b9a6-9221be1b7749
📒 Files selected for processing (1)
scripts/menu_recovery.sh
There was a problem hiding this comment.
🧹 Nitpick comments (1)
scripts/menu_recovery.sh (1)
76-153: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winExtract the repeated cleanup-and-fail boilerplate.
The
zpool export ...; rmdir ...; ui_msg ...; return 1sequence is duplicated across ~9 failure branches in this function. In credential-handling code, duplicated cleanup logic risks silent divergence if one branch is updated later and others aren't.♻️ Proposed helper extraction
+reset_cleanup_fail() { + local pool_name="$1" mount_root="$2" message="$3" + zpool export "$pool_name" >/dev/null 2>&1 || true + rmdir "$mount_root" 2>/dev/null || true + ui_msg "Password Reset" "$message" + return 1 +} + reset_unraid_password() { ... if ! zfs list -H -o name "$boot_dataset" >/dev/null 2>&1; then - zpool export "$pool_name" >/dev/null 2>&1 || true - rmdir "$mount_root" 2>/dev/null || true - ui_msg "Password Reset" "The expected boot dataset '$boot_dataset' was not found." - return 1 + reset_cleanup_fail "$pool_name" "$mount_root" "The expected boot dataset '$boot_dataset' was not found." + return 1 fi # ...repeat for each of the other ~8 failure branches🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@scripts/menu_recovery.sh` around lines 76 - 153, Extract the repeated zpool export, mount-root removal, error dialog, and return-1 sequence into a local helper for this recovery function, then replace each failure branch’s duplicated cleanup-and-fail block with that helper while preserving each branch’s existing message and failure behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@scripts/menu_recovery.sh`:
- Around line 76-153: Extract the repeated zpool export, mount-root removal,
error dialog, and return-1 sequence into a local helper for this recovery
function, then replace each failure branch’s duplicated cleanup-and-fail block
with that helper while preserving each branch’s existing message and failure
behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 343836a9-93ea-40c4-ba0b-a29312c1f4b6
📒 Files selected for processing (1)
scripts/menu_recovery.sh
Summary
Summary by CodeRabbit