Skip to content

fix: prevent restore crash and revert loop on node switching#468

Merged
grunch merged 1 commit intomainfrom
fix/restore-orders-offline-mostro
Feb 14, 2026
Merged

fix: prevent restore crash and revert loop on node switching#468
grunch merged 1 commit intomainfrom
fix/restore-orders-offline-mostro

Conversation

@grunch
Copy link
Member

@grunch grunch commented Feb 14, 2026

Add null-safety to _extractOrdersDetails() in RestoreService to handle unexpected null values from Mostro responses, matching the defensive pattern already used in _extractRestoreData().

Remove the revert-on-failure logic in MostroNodeSelector that caused a loop: when restore failed, reverting to the old (potentially offline) node triggered a second restore that also failed, leaving the user stuck with wiped data. Now the user stays on the new node and sees an error.

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced error messaging during node switching operations to provide clearer feedback when connection issues occur
    • Improved application stability by adding comprehensive validation and null-safety checks to message parsing logic, preventing potential crashes from incomplete or malformed data structures

Add null-safety to _extractOrdersDetails() in RestoreService to handle
unexpected null values from Mostro responses, matching the defensive
pattern already used in _extractRestoreData().

Remove the revert-on-failure logic in MostroNodeSelector that caused a
loop: when restore failed, reverting to the old (potentially offline)
node triggered a second restore that also failed, leaving the user stuck
with wiped data. Now the user stays on the new node and sees an error.
@grunch grunch requested a review from mostronator February 14, 2026 10:27
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 14, 2026

Walkthrough

This PR removes the restore retry mechanism and progress overlay handling from the node selector when node switching fails, and adds null-safety guards to the restore manager's order extraction logic to prevent runtime errors on malformed Mostro messages.

Changes

Cohort / File(s) Summary
Node Selector Error Handling
lib/features/mostro/widgets/mostro_node_selector.dart
Removed restore retry logic (progress overlay hiding, node revert, re-initialization) on failed restore. Updated error message to use "errorSwitchingNode" instead of "nodeNotRespondingReverted". Removed restore\_progress\_notifier import.
Restore Manager Resilience
lib/features/restore/restore_manager.dart
Added null-safety checks in _extractOrdersDetails to handle missing payload data, cant-do messages, null order wrappers, and null payloads. Returns empty OrdersResponse with warning logs for each guard case.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • Phase 3 UI mostrod select #440: Directly reverts the restore-revert and restore-progress overlay handling that was introduced in this prior PR, as this change removes that functionality.

Suggested reviewers

  • AndreaDiazCorreia
  • BraCR10

Poem

🐰 A rabbit hops through node selection,
No more retries, just smooth direction,
Guard clauses catch what's not quite right,
Empty responses shine so bright,
Error handling, graceful and neat!

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: preventing restore crashes and removing the revert loop when switching nodes, which are the core objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ 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
  • Commit unit tests in branch fix/restore-orders-offline-mostro

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
lib/features/restore/restore_manager.dart (1)

819-820: Raw exception message exposed in UI via showError().

e.toString() is passed directly to showError(), which surfaces technical error details to the user. The full error is already logged on line 818 via logger.e().

Suggested fix
-      final errorMessage = e.toString();
-      ref.read(restoreProgressProvider.notifier).showError('Restore failed: $errorMessage');
+      ref.read(restoreProgressProvider.notifier).showError('Restore failed');

Based on learnings: "Do not show raw exception messages in the UI for user-facing errors in the restore feature. In showError() calls, avoid displaying e.toString() or full stack traces. Log full error details with logger.e() for debugging, and surface sanitized, user-friendly messages to the UI."


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.

@grunch grunch merged commit fe41511 into main Feb 14, 2026
2 checks passed
@grunch grunch deleted the fix/restore-orders-offline-mostro branch February 14, 2026 10:31
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