Skip to content

Fix ReportWindow crash when log directory is empty or missing#4338

Merged
VictoriousRaptor merged 3 commits into
devfrom
copilot/fix-appearance-setting-error
Mar 10, 2026
Merged

Fix ReportWindow crash when log directory is empty or missing#4338
VictoriousRaptor merged 3 commits into
devfrom
copilot/fix-appearance-setting-error

Conversation

@Jack251970
Copy link
Copy Markdown
Member

@Jack251970 Jack251970 commented Mar 10, 2026

Resolve #4326


Summary by cubic

Summary of changes
Fixes a crash in ReportWindow when the log directory is missing, empty, or unreadable by safely handling IO errors and absent log files. The UI only prompts to upload a log when a log file exists.

Bug Fixes

  • Changed: SetException now verifies directory existence and uses FirstOrDefault() for the latest log.
  • Added: Try/catch around log discovery, a null-check before adding the “upload log” hint, and clearer code comments explaining the defensive handling.
  • Removed: The assumption that a log directory and at least one log file always exist.
  • Memory: No meaningful impact.
  • Security: No new risks; avoids exposing paths unless a log is present and intended to be shown.
  • Tests: No unit tests added.

Written for commit b1d98f6. Summary will update on new commits.

Copilot AI and others added 2 commits March 10, 2026 05:18
Co-authored-by: Jack251970 <53996452+Jack251970@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 10, 2026 05:37
@prlabeler prlabeler Bot added the bug Something isn't working label Mar 10, 2026
@github-actions github-actions Bot added this to the 2.2.0 milestone Mar 10, 2026
@gitstream-cm
Copy link
Copy Markdown

gitstream-cm Bot commented Mar 10, 2026

🥷 Code experts: no user but you matched threshold 10

Jack251970 has most 👩‍💻 activity in the files.
Jack251970 has most 🧠 knowledge in the files.

See details

Flow.Launcher/ReportWindow.xaml.cs

Activity based on git-commit:

Jack251970
MAR
FEB
JAN
DEC
NOV
OCT

Knowledge based on git-blame:
Jack251970: 100%

✨ Comment /gs review for LinearB AI review. Learn how to automate it here.

@gitstream-cm
Copy link
Copy Markdown

gitstream-cm Bot commented Mar 10, 2026

Be a legend 🏆 by adding a before and after screenshot of the changes you made, especially if they are around UI/UX.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a crash in ReportWindow when opening the appearance settings page and the version log directory is missing or contains no log files (resolving #4326).

Changes:

  • Guard log discovery with directory-existence checks and FirstOrDefault() to avoid Sequence contains no elements.
  • Wrap log lookup in a try/catch and only show the “upload log” prompt when a log file is found.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Flow.Launcher/ReportWindow.xaml.cs Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 10, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 22bac45d-5f82-409a-9861-2fec9d002d99

📥 Commits

Reviewing files that changed from the base of the PR and between e1339e5 and b1d98f6.

📒 Files selected for processing (1)
  • Flow.Launcher/ReportWindow.xaml.cs

📝 Walkthrough

Walkthrough

Made ReportWindow's log discovery and usage robust by adding try/catch around log retrieval, checking the logs directory exists, using FirstOrDefault instead of First, and guarding log usage with a null check.

Changes

Cohort / File(s) Summary
Log retrieval and error-report UI
Flow.Launcher/ReportWindow.xaml.cs
Wrap log discovery in try/catch, check directory existence before enumerating files, replace First() with FirstOrDefault(), and add null checks before appending/uploading the log to avoid exceptions when no log exists or IO errors occur.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • jjw24
  • VictoriousRaptor
🚥 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 directly describes the main change: fixing a ReportWindow crash when the log directory is empty or missing, which matches the primary objective.
Description check ✅ Passed The description is related to the changeset, linking to issue #4326 and explaining how the changes fix the crash by safely handling IO errors and absent log files.
Linked Issues check ✅ Passed The changes directly address issue #4326 by implementing safe log discovery with try/catch, directory existence checks, FirstOrDefault instead of First, and null-checks to prevent the InvalidOperationException.
Out of Scope Changes check ✅ Passed All changes are scoped to ReportWindow.xaml.cs and focused on fixing the log-discovery crash; no unrelated modifications were introduced.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch copilot/fix-appearance-setting-error

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

🧹 Nitpick comments (1)
Flow.Launcher/ReportWindow.xaml.cs (1)

51-53: Narrow the catch or broaden the comment.

This currently swallows every exception type, while the comment says only IO errors are being ignored. Catch the expected filesystem exceptions here, or update the comment so it matches the behavior.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Flow.Launcher/ReportWindow.xaml.cs` around lines 51 - 53, The catch block
currently uses a broad catch (Exception) while the comment says only IO errors
are intended to be ignored; narrow the catch to the filesystem-related
exceptions (e.g., catch IOException and also consider
UnauthorizedAccessException, PathTooLongException,
DirectoryNotFoundException/FileNotFoundException) around the code that finds the
log file in ReportWindow.xaml.cs, or alternatively update the comment to state
that all exceptions are being swallowed — prefer narrowing the catch to the
specific exceptions so only expected filesystem errors are ignored and other
errors still surface.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@Flow.Launcher/ReportWindow.xaml.cs`:
- Around line 51-53: The catch block currently uses a broad catch (Exception)
while the comment says only IO errors are intended to be ignored; narrow the
catch to the filesystem-related exceptions (e.g., catch IOException and also
consider UnauthorizedAccessException, PathTooLongException,
DirectoryNotFoundException/FileNotFoundException) around the code that finds the
log file in ReportWindow.xaml.cs, or alternatively update the comment to state
that all exceptions are being swallowed — prefer narrowing the catch to the
specific exceptions so only expected filesystem errors are ignored and other
errors still surface.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 35867006-a3ef-48b9-aa96-22902a4a52bd

📥 Commits

Reviewing files that changed from the base of the PR and between 24f6c90 and e1339e5.

📒 Files selected for processing (1)
  • Flow.Launcher/ReportWindow.xaml.cs

@coderabbitai coderabbitai Bot removed the bug Something isn't working label Mar 10, 2026
@Jack251970 Jack251970 added the bug Something isn't working label Mar 10, 2026
@VictoriousRaptor VictoriousRaptor merged commit a406eb8 into dev Mar 10, 2026
15 checks passed
@VictoriousRaptor VictoriousRaptor deleted the copilot/fix-appearance-setting-error branch March 10, 2026 12:29
@jjw24 jjw24 modified the milestones: 2.2.0, 2.1.2 May 9, 2026
jjw24 pushed a commit that referenced this pull request May 9, 2026
* Initial plan

* Fix ReportWindow crash when log directory is empty or doesn't exist

Co-authored-by: Jack251970 <53996452+Jack251970@users.noreply.github.com>

* Improve code comments

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: Error on constructing ReportWindow

5 participants