Skip to content

Windows paths #11

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

Merged
merged 2 commits into from
Aug 1, 2019
Merged

Windows paths #11

merged 2 commits into from
Aug 1, 2019

Conversation

philnash
Copy link
Contributor

@philnash philnash commented Aug 1, 2019

@devinrader was having difficulties deploying a function within a subdirectory on Windows. Ultimately the error message was:

{"message":"Path provided is invalid.","code":20001,"user_error":true,"http_status_code":400,"params":{}}' }

The issue was a function in $PROJECT_DIR/functions/sms/reply.js and the error was:

Error: Failed to upload Function /sms\reply

With an amount of VSCode live share and messing around, changing this line from functions.ts:

form.append('Path', fn.path);

to

form.append('Path', fn.path.replace(/\\/g, '/'));

got the deploy to work. The output still showed:

Functions:
   https://fancy-domain-3313-dev.twil.io/sms\foo

I stepped back to see where the path was coming from and I traced it back to getPathAndAccessFromFileInfo. upath was already in the dependency tree, so I promoted it to direct dependency and used toUnix to turn the eventual path of both functions and assets into something the API will understand.

This was painful working through the issue with a windows machine an ocean and a continent away, so I am not 100% confident that this does now work for all machines. I recommend testing against deployments on Mac and Windows with functions and assets in subfolders to ensure this is now working cross platform.

Thoughts?

Contributing to Twilio

All third-party contributors acknowledge that any contributions they provide will be made under the same open-source license that the open-source project is provided under.

  • I acknowledge that all my contributions will be made under the project's license.

@philnash philnash requested a review from dkundel August 1, 2019 03:40
@dkundel
Copy link
Contributor

dkundel commented Aug 1, 2019

Oh that’s a good catch. Thanks for jumping on this. From reading the lib on my phone, this seems fine. I wonder if we should do a change here as well:

const name = path.relative(dir, filePath);

That's largely used for naming things. Stefan's serverless framework integration for example lets you set the name explicitly.

I think we should turn it into UNIX because there might otherwise be issues because the name is used during deployment to look up the right Function/Asset to update. So two devs working on different platforms could have an issue.

@dkundel
Copy link
Contributor

dkundel commented Aug 1, 2019

Example for Functions (same happens in Assets)

const existingFn = existingFunctions.find(f => fn.name === f.friendly_name);

@dkundel
Copy link
Contributor

dkundel commented Aug 1, 2019

Actually never mind my comment before. This looks good. I'll test it on Mac because it should at least not break existing behavior and then release a private build that I'll let Devin test.

@dkundel dkundel merged commit 9c74b44 into twilio-labs:master Aug 1, 2019
@philnash
Copy link
Contributor Author

philnash commented Aug 1, 2019

I think you might be right from your comment before though... Let's test, but normalising the names and paths across OSes does seem important overall.

@dkundel
Copy link
Contributor

dkundel commented Aug 2, 2019

Yes but I realized afterwards that the name gets actually overwritten by the path here:

name: path,

@philnash
Copy link
Contributor Author

philnash commented Aug 2, 2019

If we have a name and a path variable but one writes over the other, should we consolidate it to just the one of them?

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.

2 participants