-
Notifications
You must be signed in to change notification settings - Fork 352
NAS-138278 / 26.04 / Uploading VM Image File in /mnt #12795
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: master
Are you sure you want to change the base?
Conversation
Add validation to prevent uploading ISO files to /mnt or pool roots: - Default path is /mnt which causes '[EINVAL] path must reside within a pool mount point' error - Add validateNotPoolRoot validator to reject /mnt and pool root paths - Normalize paths by removing trailing slashes before validation - Add translated error message to vm-wizard helptext - Add comprehensive test coverage for path validation scenarios The Upload button is now disabled when an invalid path is selected, preventing files from being uploaded to the boot drive's /mnt folder and the subsequent VM creation error.
Created shared validator to eliminate code duplication: 1. Added validateNotPoolRoot() to app/modules/forms/ix-forms/validators/validators.ts - Validates that paths are not /mnt or pool roots (/mnt/poolname) - Accepts optional custom error message - Properly normalizes paths and handles trailing slashes - Added comprehensive test suite (12 tests total) 2. Updated upload-iso-dialog.component.ts to use shared validator - Removed 21 lines of duplicate validation code - Uses custom error message from helptext 3. Updated export-disk-dialog.component.ts to use shared validator - Removed 21 lines of duplicate validation code - Uses custom error message from helptext 4. Fixed tests to use valid dataset paths (/mnt/pool/dataset) instead of pool roots (/mnt/pool) All 18 component tests and 12 validator tests passing.
1. Enhanced validator documentation - Added detailed explanation of why pool roots are invalid - Explained backend requirements and security considerations - Clarified that operations should target specific datasets 2. Improved test coverage - Split trailing slash tests into separate test cases - Added explicit test for multiple trailing slashes (/mnt/tank//////) - Now 13 validator tests instead of 12 3. Documented empty path default behavior - Added comment explaining why path starts empty instead of '/mnt' - Empty path avoids immediate validation error and better UX - Users navigate to valid dataset using file explorer Note: mntPath import removal is correct - the constant is still used elsewhere in the codebase for other file explorer components. All 31 tests passing.
Changed validateNotPoolRoot to require a translated error message parameter instead of having an optional parameter with English default fallback. Why: - Validators should not contain hardcoded English text for proper i18n - All callers already pass translated messages via translate.instant() - Making it required ensures future uses will also provide translations - Better API design - makes i18n requirement explicit Changes: 1. validators.ts: Changed errorMessage from optional to required parameter 2. validators.ts: Updated JSDoc to emphasize translation requirement 3. validators.ts: Removed English default fallback message 4. validators.spec.ts: Updated all tests to pass required error message 5. validators.spec.ts: Renamed test from "should use custom error message" to "should use the provided translated error message" All 31 tests passing.
|
Claude finished @AlexKarpov98's task —— View job Code Review Complete! ✅Great work on this PR! The validator refactoring is solid and the test coverage is excellent. Here are my findings: 🎯 What Works WellThe new Issues to Address1. UX Issue: Initial Path Behavior 🔴 The current implementation starts with an empty path, which immediately shows a validation error when users open the dialog because the path field is required but empty. This creates a confusing UX where users see an error before they've done anything wrong. Suggestion: Consider one of these approaches:
2. Missing LoaderService Methods 🟡 The code calls Suggestion: Add these methods to the LoaderService mock: mockProvider(LoaderService, {
open: jest.fn(() => of(true)),
close: jest.fn(),
setTitle: jest.fn(),
setConfirmationBeforeClose: jest.fn(),
removeConfirmationBeforeClose: jest.fn(),
}),3. Minor: Test Assertion Gap 🟡 The test "cancels upload and cleans up when component is destroyed" comments that it verifies the subscription was cancelled, but the assertion doesn't actually verify this - it only checks that the subject itself still emits. Consider verifying that the cancel function was actually called. 📋 SummaryTwo minor issues to address: the empty path UX could be improved, and LoaderService mock methods should be added for robustness. Otherwise, the code quality is excellent with great test coverage and clean refactoring! 🚀 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #12795 +/- ##
=======================================
Coverage 86.28% 86.28%
=======================================
Files 1825 1825
Lines 67908 67917 +9
Branches 8219 8222 +3
=======================================
+ Hits 58593 58604 +11
+ Misses 9315 9313 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Testing: see ticket.
Go to VM page, go to the
Installation Mediastep and clickUpload New Image FilePreview:
Refactored code to avoid code duplications, added more tests for form validator.