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

hs upload can upload folders to Design Manager with names that later cause hs fetch to report an error #579

Open
yellcorp opened this issue Oct 27, 2021 · 2 comments

Comments

@yellcorp
Copy link

yellcorp commented Oct 27, 2021

Description and Context

There seems to be asymmetry between what hs upload will upload vs what hs fetch will download. It is possible to upload a folder (directory) with a name that later causes hs fetch to halt with an error. I can confirm this happens with folder names containing a period/full-stop. Other non-alphanumeric characters seem to be denied by hs upload.

That the hs upload and hs fetch subcommands have different restrictions on folder naming is unintuitive, hard for a user to internalize, and can introduce significant time between when the error condition is created vs when it is reported, possibly after significant work in Design Manager has already taken place.

Versions:

@hubspot/[email protected]
node v16.6.1
npm 7.20.3

Steps to reproduce

Requirements: A working installation of hs with credentials that allow uploading to Design Manager. hs list should complete successfully.

At a shell:

mkdir test.folder
echo "<!DOCTYPE html>" > test.folder/test.html
hs upload test.folder /test.folder

Observe output:

Uploading files from "test.folder" to "/test.folder" in the Design Manager of account {account}
Uploaded file "{cwd}/test.folder/test.html" to "/test.folder/test.html"
[SUCCESS] Uploading files to "/test.folder" in the Design Manager is complete

Confirm folder and contents were uploaded

hs list /test.folder

Output:

test.html

Try to fetch uploaded folder and contents

mkdir test_fetch
hs fetch /test.folder test_fetch

Output:

[ERROR] Invalid file type requested: "/test.folder"
[ERROR] Failed fetch of file "/test.folder" to "{cwd}/test_fetch" from the Design Manager

Workaround:

  • Locate test.folder in Design Manager's Web UI
  • Right click and choose 'Rename folder'
  • Type "test_folder"
  • Accept confirmation dialogs
    At a shell:
hs fetch /test_folder test_fetch

Output:

Fetched "/test_folder" from account {account} from the Design Manager successfully
Skipped existing "{cwd}/test_fetch"
Wrote file "{cwd}/test_fetch/test.html"
[SUCCESS] Completed fetch of folder "/test_folder" to "{cwd}/test_fetch" from the Design Manager

A second partial workaround exists in that individual files can be downloaded:

hs fetch /test.folder/test.html test_fetch

Output:

Wrote file "{cwd}/test_fetch/test.html"
[SUCCESS] Completed fetch of file "/test.folder/test.html" to "{cwd}/test_fetch/test.html" from the Design Manager

But this is not a complete workaround as it does not result in the entire folder being downloaded.

Expected behavior

Either:

  1. hs upload denies the upload of test.folder with an error.
    OR
  2. The hs fetch /test.folder test_fetch step completes successfully, downloading the contents of /test.folder from Design Manager into the local folder test_fetch.

Is something in hs fetch testing the name against a whitelist of file extensions before checking that the remote resource is a folder?

@anthmatic
Copy link
Contributor

Thanks for the detailed issue @yellcorp! I was able to reproduce this easily and I can see that this is caused by the method the CLI uses to determine whether the source path string is a file or directory.

Unfortunately, there isn't a clear path forward to fix this yet but we'll update this issue when we find a solution.

@paul-c-guest
Copy link

This problem still exists in the current version 5.3.0. Is there any progress on the issue?
We have production code residing in a folder that contains a period/dot character (e.g. projectName2.0/), so are unable to fetch that folder.
Our workaround (HTTP requests are swiftly handed on to code in a project/folder that we can fetch) introduces complexity that shouldn't be necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants