-
Notifications
You must be signed in to change notification settings - Fork 21
Fix for VSC windows #948
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fix for VSC windows #948
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
|
@mashraf-222 tests are failing |
…nd added safty check
|
this feels extremely complicated for what should be a simple fix, can you fix the merge conflicts and I'll review it again. |
| # Attempt to remove worktree using git command with retries | ||
| for attempt in range(max_retries): | ||
| try: | ||
| attempt_num = attempt + 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q: Not sure if this will execute successfully on win for multiple retries. If this then as discussed , this might also require some time delay.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the loop starts with for attempt in range(max_retries):, which tries up to 3 times for windows, each iteration calls repository.git.worktree("remove", "--force", str(worktree_dir)). If it succeeds, it returns immediately.
If it fails, the code catches git.exc.GitCommandError and checks if the error message contains "permission denied" or "access is denied" to determine if it's a permission error. The condition if is_permission_error and attempt < max_retries - 1: decides whether to retry: it must be a permission error and not the last attempt.
When retrying, it logs the retry, then calls time.sleep(retry_delay), which starts at 0.5 seconds and doubles each time (0.5s then 1.0s then 2.0s). This gives Windows time to release file locks. After the sleep, retry_delay *= 2 increases the delay for the next retry, and the loop continues.
…ss handling as execute_test_subprocess
I fixed the conflicts and the workflow tests, it looks extremely complicated because this PR is fixing lots of bugs for windows vsc. |
Windows Compatibility Fixes for CodeFlash CoreThis PR addresses critical Windows compatibility issues that were preventing the CodeFlash extension from working correctly on Windows systems. These fixes ensure reliable subprocess execution, proper file handling, and consistent path resolution across all platforms. OverviewThe changes in this PR focus on fixing Windows-specific bugs related to subprocess management, file locking, path resolution, and LSP communication. These issues were causing hangs, crashes, and incorrect behavior when running CodeFlash on Windows. Bugs Fixed1. Subprocess Deadlocks on Windows
2. File Locking Issues in Git Worktrees
3. Inconsistent Path Resolution
4. LSP Message Delimiter Parsing Error
5. Malformed Windows Paths in LSP
6. Coverage Database File Locking
7. Console Window Spawning in LSP Mode
8. LSP Progress Bar Compatibility
Code Changes SummaryCore Subprocess Handling
Git Worktree Management
Path Resolution
LSP Integration
Test Discovery
Related ChangesThis PR complements our internal PR that fixes Windows path handling in the VSCode extension UI components. Together, these changes ensure full Windows compatibility across the entire CodeFlash ecosystem. |
|
@mashraf-222 status on this? |
waiting for a review. |
PR Review: Fix for VSC windows (PR #948)OverviewThis PR addresses Windows compatibility issues in the CodeFlash LSP integration, focusing on path normalization, subprocess handling, and git worktree management. The changes are comprehensive and well-documented. ✅ Strengths1. Excellent Documentation
2. Robust Error Handling
3. Safety-First Approach
|
- Path Traversal Protection - Replace Bare Exception Handlers - Test Discovery Logging
PR Review: Fix for VSC WindowsThis PR addresses Windows path compatibility issues across multiple modules. Overall, the changes are well-structured and address legitimate cross-platform concerns. Below is my detailed review: ✅ Strengths1. Windows Compatibility Improvements
2. Robust Error Handling
3. Code Documentation
🔴 Critical Issues1. Path Traversal Validation is Insufficient
|
| Category | Rating | Notes |
|---|---|---|
| Code Quality | 🟢 Good | Well-structured, good documentation |
| Security | 🟡 Fair | Path validation is flawed but low actual risk |
| Performance | 🟢 Good | Acceptable overhead for correctness |
| Windows Compatibility | 🟢 Excellent | Comprehensive Windows fixes |
| Error Handling | 🟢 Good | Robust retry logic, some minor issues |
| Test Coverage | 🔴 Poor | Missing tests for new Windows code paths |
🎯 Recommendations Priority
High Priority:
⚠️ Fix or remove the flawed path traversal validation⚠️ Add tests for Windows-specific code paths
Medium Priority:
3. Consolidate redundant path resolution logic
4. Improve subprocess error handling consistency
Low Priority:
5. Extract magic numbers to constants
6. Make exception handling more specific
7. Fix DummyProgress type compatibility
✅ Approval Status
Conditional Approval - This PR significantly improves Windows compatibility and is well-implemented overall. However, I recommend addressing the critical path traversal validation issue before merging to avoid potential false positives in production.
Great work on the comprehensive Windows compatibility fixes! The retry logic and error handling are particularly well done. 👍
Code Review: Windows Compatibility Fixes (PR #948)SummaryThis PR addresses Windows compatibility issues in the VSCode extension by normalizing paths, handling file locking, and improving subprocess management. The changes are comprehensive and well-structured, with strong attention to cross-platform compatibility. ✅ Strengths1. Excellent Path Normalization
2. Robust Windows File Locking Handling
3. Strong Security Practices
4. Improved Error Handling
🔍 Issues & RecommendationsRequired ChangesNone identified - all critical issues have been addressed in the latest commit. Suggested Improvements (Minor)1. Performance - Redundant Path ResolutionLocation: functions_to_optimize.py:746-752 The code resolves file paths twice. Consider consolidating by using _resolve_path_consistent() directly. 2. Code Organization - Extract ConstantsLocation: git_worktree_utils.py:76 The long list of binary file exclusions could be extracted to a module-level constant for better maintainability. 3. Error Handling - Log Level ConsistencyLocation: discover_unit_tests.py:627-640 Consider using logger.warning() for non-critical failures where falling back to empty test lists is acceptable. 🎯 Code Quality Assessment
🏁 RecommendationAPPROVE ✅ This PR is ready to merge. The Windows compatibility fixes are well-implemented with strong attention to:
The suggested improvements are minor and can be addressed in future PRs if desired. The core functionality is solid and the code quality is high. Great work on addressing the Windows compatibility issues! 🎉 |
PR Review: Fix for VSC WindowsThis PR addresses Windows compatibility issues in the VSCode extension. Overall, this is a well-implemented fix with robust error handling and good documentation. Here's my detailed review: ✅ Strengths1. Excellent Windows-Specific Subprocess Handling
2. Robust Path Resolution
3. Comprehensive Error Handling
4. Security Improvements
5. Improved Logging
|
- Consolidated path validation logic to prevent traversal attacks. - Improved error handling in subprocess calls for test discovery, preserving command arguments for better context. - Updated Windows-specific wait times for file release during cleanup. - Enhanced readability and maintainability of path resolution functions.
Pull Request Review: Fix for VSC Windows (#948)OverviewThis PR addresses Windows compatibility issues with path handling, LSP initialization, and worktree management. The changes are extensive but well-focused on cross-platform compatibility. ✅ Strengths1. Robust Windows Path Handling
2. Security ConsiderationsThe path traversal validation in def _validate_path_no_traversal(path: Path | str) -> bool:
"""Validate that a path does not contain path traversal components."""This defensively prevents path traversal attacks even though paths come from trusted sources. 3. Comprehensive Error Handling
4. Documentation
|
PR Type
Bug fix, Enhancement
Description
Normalize paths for Windows compatibility
Use worktree paths in LSP initialization
Robust relative path computation with fallbacks
Case-insensitive filtering of files
Diagram Walkthrough
File Walkthrough
functions_to_optimize.py
Case-insensitive path filtering for Windowscodeflash/discovery/functions_to_optimize.py
beta.py
Use resolved worktree paths in LSP initcodeflash/lsp/beta.py
optimizer.py
Robust mirror_path with Windows-safe normalizationcodeflash/optimization/optimizer.py