Skip to content

fix: avoid startup crash when saved appdata path is unavailable#259

Open
nickogl wants to merge 1 commit into
TeamWheelWizard:mainfrom
nickogl:main
Open

fix: avoid startup crash when saved appdata path is unavailable#259
nickogl wants to merge 1 commit into
TeamWheelWizard:mainfrom
nickogl:main

Conversation

@nickogl
Copy link
Copy Markdown

@nickogl nickogl commented May 13, 2026

Purpose of this PR:

WheelWizard could crash on startup at logger initialization when a previously saved custom data folder points to an unavailable path (for example after external drive letter changes). This PR fixes the root cause by making appdata-path resolution resilient.

How to Test:

  • Set HKCU\Software\WheelWizard\AppDataLocation to a path on an unavailable drive (for example Z:\... where Z: does not exist).
  • Start WheelWizard.
  • Confirm startup no longer crashes due to missing appdata path.

What Has Been Changed:

  • PathManager now ignores persisted custom appdata paths that cannot be created/accessed and falls back to default appdata path for startup.
  • Added a regression test for unavailable target-path behavior via public PathManager API.

Checklist before merging

  • You have created relevant tests

Discussion points

Logger initialization failures did not surface anywhere but the Windows event logs (at least for me), which makes diagnosis harder for end users. A follow-up improvement could be either to add a fallback sink or improve the way this error surfaces to the end user.

Summary by CodeRabbit

  • Tests

    • Added tests for appdata path validation to ensure proper error handling when paths are unavailable.
  • Bug Fixes

    • Enhanced appdata path validation with improved error reporting and accessibility checks.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 13, 2026

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: b3f01047-0c9d-4f33-a68e-80b4a43d1a80

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

A new appdata path validation layer is added to PathManager that normalizes persisted paths, filters default values, and validates directory accessibility through a helper method. A Windows-only test ensures unavailable network paths are properly rejected with error reporting.

Changes

Appdata Path Validation with Accessibility Checking

Layer / File(s) Summary
Appdata path accessibility validation
WheelWizard/Services/PathManager.cs
LoadSavedWheelWizardAppdataOverride normalizes the persisted override path, compares it against the default to filter equivalents, and validates directory accessibility via a new private helper TryEnsureWheelWizardAppdataPathAccessible that wraps directory-ensure operations with exception handling.
Unavailable path rejection test
WheelWizard.Test/Features/Settings/PathManagerTests.cs
A Windows-only xUnit test verifies that TrySetWheelWizardAppdataPath returns false and provides a non-empty error message when attempting to set an appdata path to an unavailable UNC network location.

🎯 2 (Simple) | ⏱️ ~12 minutes

🐰 A path's been smoothed with safety in mind,
Normalize, compare, ensure paths aligned,
When networks are slow or simply not there,
WheelWizard checks twice and handles with care!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: fixing a startup crash by making appdata path resolution resilient to unavailable paths.
Description check ✅ Passed The description covers all required template sections with sufficient detail and marks the test checklist as complete.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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
Copy Markdown

@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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@WheelWizard.Test/Features/Settings/PathManagerTests.cs`:
- Around line 21-24: GetUnavailableWindowsPath currently returns a UNC host path
which can hang on DNS resolution; change it to return a deterministic unused
local drive-letter path so failures are immediate. Update the
GetUnavailableWindowsPath method to return a path like
$@"Z:\WheelWizardTests\{Guid.NewGuid():N}" (or better: pick an unused drive
letter by checking DriveInfo.GetDrives() and return the first free letter)
instead of the UNC \\nonexistent-host\... value.
🪄 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: ASSERTIVE

Plan: Pro

Run ID: a6d359d4-6869-4a86-99df-0ee15a9eff84

📥 Commits

Reviewing files that changed from the base of the PR and between 33a59db and d2f97fd.

📒 Files selected for processing (2)
  • WheelWizard.Test/Features/Settings/PathManagerTests.cs
  • WheelWizard/Services/PathManager.cs

Comment thread WheelWizard.Test/Features/Settings/PathManagerTests.cs
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