fix: add cross-platform path validation and graceful error handling#52
Open
samalbishnupriya06-stack wants to merge 1 commit into
Conversation
- Add validate_path() helper in Rust backend using std::path - Wrap all file system commands with OS-aware error messages - Create src/utils/pathValidator.ts for frontend input validation - Normalize path separators before invoking Tauri commands - Replace raw stack traces with user-friendly error strings Closes Kanwaljeet1#34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Addresses the input validation and cross-platform path handling issue.
The tool previously risked crashes on malformed paths or mismatched OS separators.
Changes Made
Backend (
src-tauri/src/main.rs)validate_path()helper usingstd::path::Pathfor OS-agnostic path resolution../stripping)fs::operations withmatch e.kind()to return human-readable errors instead of panicsFrontend (
src/utils/pathValidator.ts) — New fileinvoke()callFrontend (
src/services/optimizer.ts)ErrorobjectsType of Change
How to Test
npm run tauri dev../../etc/passwd→ should show validation error, not crashChecklist
cargo checkpasses with no errorsnpm run type-checkpassesRelated Issue
Closes #34