Fixing issue number #283 "New Project creation has "The project name should not contain space between them" even though there is no space. #283" #373
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.
Related Issues
Closes: #283
Problem Statement
Users on Ubuntu 20.04, Windows 11 (64-bit), and other OS versions were encountering a false positive validation error:
This error occurred even when the project name itself did not contain any spaces. The issue was causing:
Root Cause Analysis
The validation logic in
Validation.py
was incorrectly checking the entire project path (projDir
) for whitespace instead of only the project name. This meant that if any parent directory in the path contained spaces (which is common in paths like/home/user name/Documents/
), the validation would fail even for valid project names.Solution Overview
This PR implements a targeted fix to resolve the validation issue:
Fixed Validation Logic in
Validation.py
Before (Problematic Code):
After (Fixed Code):
Impact: This dual approach ensures:
projName
) for spaces, not the full path with parent directories (projDir
)_
) instead of throwing a validation errorEnhanced Input Sanitization in
newProject.py
Before (Limited Handling):
After (Comprehensive Sanitization):
How This Addresses the Problem
✅ Eliminates False Positives
✅ Improves User Experience
_
) instead of throwing an error✅ Maintains Data Integrity
Testing Performed
Files Modified
src/projManagement/Validation.py
- Fixed validation logic to check only project nameprojName = os.path.basename(projDir)
and updated validation checksrc/projManagement/newProject.py
- Enhanced input sanitization with space replacementrstrip().lstrip()
withstrip().replace(" ", "_")
Breaking Changes
None. This is a backward-compatible fix that only resolves the false positive issue without changing the core functionality.
Additional Notes
This fix resolves the core validation issue while maintaining the spirit of the original validation rule. Project names will still be clean and filesystem-friendly, but users will no longer encounter false validation errors due to their system's directory structure.
The changes are minimal and focused, addressing the specific issue without introducing unnecessary complexity or dependencies.