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

Windows fs symlink TypeError on Buffer target value #34514

Closed
AlexanderOMara opened this issue Jul 26, 2020 · 5 comments
Closed

Windows fs symlink TypeError on Buffer target value #34514

AlexanderOMara opened this issue Jul 26, 2020 · 5 comments
Labels
confirmed-bug Issues with confirmed bugs. fs Issues and PRs related to the fs subsystem / file system. windows Issues and PRs related to the Windows platform.

Comments

@AlexanderOMara
Copy link
Contributor

AlexanderOMara commented Jul 26, 2020

  • Version: 14.5.0+
  • Platform: Windows 10 x64
  • Subsystem: fs

What steps will reproduce the bug?

On Windows:

const fs = require('fs');
fs.symlinkSync(Buffer.from('target'), 'link');

How often does it reproduce? Is there a required condition?

Always happens on Windows since 14.5.0, it may be necessary to enable symlink support on Windows (I'm not 100% sure how that all works). Does not happen on Linux or macOS.

What is the expected behavior?

No error, and the symlink should be created. Buffer is listed as a valid target type.

What do you see instead?

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received an instance of Buffer

internal/validators.js:121
    throw new ERR_INVALID_ARG_TYPE(name, 'string', value);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received an instance of Buffer
    at validateString (internal/validators.js:121:11)
    at Object.isAbsolute (path.js:353:5)
    at preprocessSymlinkDestination (internal/fs/utils.js:345:18)
    at Object.symlinkSync (fs.js:1118:19)
    at Object.<anonymous> (C:\Users\travis\build\AlexanderOMara\issue-node-symlink-buffer-windows\main.js:5:4)
    at Module._compile (internal/modules/cjs/loader.js:1236:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1257:10)
    at Module.load (internal/modules/cjs/loader.js:1085:32)
    at Function.Module._load (internal/modules/cjs/loader.js:950:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12) {
  code: 'ERR_INVALID_ARG_TYPE'
}

Additional information

I created a test repo which is tested via Travis CI.

On a side-note, the path argument can be a Buffer, it's just the target argument with the issue.

@AlexanderOMara AlexanderOMara changed the title Windows fs symlink TypeError on buffer target value. Windows fs symlink TypeError on Buffer target value Jul 26, 2020
@addaleax
Copy link
Member

What do you see instead?

Could you share the full stack trace?

@AlexanderOMara
Copy link
Contributor Author

Sure! Added the stack trace from Travis.

@addaleax addaleax added confirmed-bug Issues with confirmed bugs. fs Issues and PRs related to the fs subsystem / file system. windows Issues and PRs related to the Windows platform. labels Jul 26, 2020
@addaleax
Copy link
Member

@nodejs/fs

@AlexanderOMara
Copy link
Contributor Author

AlexanderOMara commented Jul 26, 2020

My guess is that this is the commit that created the issue, since path.isAbsolute (and also path.toNamespacedPath) expect a string:

a4e273b

There might also be a similar issue right above it if type is junction, depending on how path.resolve handles things that are not strings.

@3cp
Copy link

3cp commented Aug 9, 2020

It also affected v12.18.3, please release the patch to v12 too. Thx.

targos pushed a commit that referenced this issue May 1, 2021
PR-URL: #34540
Fixes: #34514
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anto Aravinth <[email protected]>
Reviewed-By: Pranshu Srivastava <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug Issues with confirmed bugs. fs Issues and PRs related to the fs subsystem / file system. windows Issues and PRs related to the Windows platform.
Projects
None yet
Development

No branches or pull requests

3 participants