Skip to content
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

Gracefully fail when directory is not detected #1947

Merged
merged 13 commits into from
Jul 29, 2024

Conversation

ariskataoka
Copy link
Member

@ariskataoka ariskataoka commented Jul 18, 2024

Description

When a user attempts to validate a non-valid folder using the vip import validate-files command, vip-cli fails ungracefully. This PR includes an error message for that scenario and also adds some unit tests for the vip import validate-files command.

Issue pointed here.

Before:

➜  vip-cli git:(trunk) ✗ node ./dist/bin/vip-import-validate-files.js ~/Downloads/wp-content.zip
✕  Error: Cannot read nested directory: /Users/ariskataoka/Downloads/wp-content.zip. Reason: ENOTDIR: not a directory, scandir '/Users/ariskataoka/Downloads/wp-content.zip'
✕ Please contact VIP Support with the following information:
TypeError: Cannot destructure property 'files' of 'nestedFiles' as it is undefined.
    at /Users/ariskataoka/Projects/vip-cli/dist/bin/vip-import-validate-files.js:43:5
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async _args.default.argv (/Users/ariskataoka/Projects/vip-cli/dist/lib/cli/command.js:444:11)
Error:  Unexpected error
Debug:  VIP-CLI v3.7.1-dev.0, Node v18.20.2, darwin 23.5.0 arm64

After:

➜  vip-cli git:(fix/import-validate-files-not-directory-error) ✗ node ./dist/bin/vip-import-validate-files.js ~/Downloads/wp-content.zip 
✕ Error: The given path is not a directory, please provide a valid directory path.

Pull request checklist

New release checklist

Steps to Test

Outline the steps to test and verify the PR here.

Example:

  1. Check out PR.
  2. Run npm run build
  3. Run node ./dist/bin/vip-import-validate-files.js any.zip
  4. Verify error message.

Copy link
Contributor

github-actions bot commented Jul 18, 2024

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Manifest Files

@ariskataoka ariskataoka force-pushed the fix/import-validate-files-not-directory-error branch 2 times, most recently from 0106e38 to e5f3219 Compare July 18, 2024 12:06
@ariskataoka ariskataoka force-pushed the fix/import-validate-files-not-directory-error branch from d9efdfb to 8cf91ac Compare July 18, 2024 13:40
@ariskataoka ariskataoka force-pushed the fix/import-validate-files-not-directory-error branch from 8bb92bb to 9abe4b4 Compare July 19, 2024 02:44
@ariskataoka ariskataoka force-pushed the fix/import-validate-files-not-directory-error branch from 085662f to 0031a35 Compare July 19, 2024 07:19
@ariskataoka ariskataoka force-pushed the fix/import-validate-files-not-directory-error branch from 07a863b to 0d8522d Compare July 23, 2024 01:26
@ariskataoka ariskataoka marked this pull request as ready for review July 23, 2024 01:45
@ariskataoka ariskataoka requested a review from a team July 23, 2024 01:45
Copy link
Contributor

@t-wright t-wright left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

@ariskataoka ariskataoka merged commit 2596d9d into trunk Jul 29, 2024
16 checks passed
@ariskataoka ariskataoka deleted the fix/import-validate-files-not-directory-error branch July 29, 2024 00:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants