Skip to content

fix(tauri): handle non-UTF-8 paths in default_data_folder_path#7577

Merged
Vanalite merged 2 commits intojanhq:mainfrom
eren-karakus0:fix/utf8-path-panic
Mar 5, 2026
Merged

fix(tauri): handle non-UTF-8 paths in default_data_folder_path#7577
Vanalite merged 2 commits intojanhq:mainfrom
eren-karakus0:fix/utf8-path-panic

Conversation

@eren-karakus0
Copy link
Contributor

Summary

  • Replace panicking unwrap() calls in default_data_folder_path with safe alternatives to prevent runtime crashes when the system data directory path contains non-UTF-8 characters.
  • data_dir().unwrap() replaced with unwrap_or_else using home directory fallback (consistent with get_configuration_file_path pattern)
  • path.to_str().unwrap() replaced with path.to_string_lossy() which substitutes invalid UTF-8 sequences with the Unicode replacement character instead of panicking
  • Removed duplicate to_str() call by reusing the path_str variable

Fixes #7572

Changes

  • src-tauri/src/core/app/commands.rs: 3 unwrap() calls replaced with safe alternatives in default_data_folder_path

Test plan

  • Normal paths (ASCII) continue to work unchanged
  • data_dir() failure gracefully falls back to home directory
  • Non-UTF-8 path characters handled via to_string_lossy() instead of panic
  • .ai.app suffix stripping logic preserved
  • cargo fmt passes

Replace panicking unwrap() calls with safe alternatives:
- data_dir().unwrap() -> unwrap_or_else with home directory fallback
- path.to_str().unwrap() -> path.to_string_lossy() for non-UTF-8 safety
- Remove duplicate to_str() call by reusing path_str variable

Fixes janhq#7572
Copy link
Contributor

@louis-jan louis-jan left a comment

Choose a reason for hiding this comment

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

LGTM

@louis-jan
Copy link
Contributor

Thank you @eren-karakus0

@Vanalite Vanalite merged commit dcf0087 into janhq:main Mar 5, 2026
17 checks passed
@github-project-automation github-project-automation bot moved this to QA in Jan Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: QA

Development

Successfully merging this pull request may close these issues.

Rust: Panic in default_data_folder_path when path is not valid UTF-8

3 participants