-
Notifications
You must be signed in to change notification settings - Fork 30k
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
ENOENT thrown when trying to create a file with an invalid filename #8987
Comments
Pretty sure that error codes comes straight from the Windows API, and it even seems consistent with macOS, so I'd lean towards leaving it as-is. Doing a check for filename validity on Windows is costly and should probably be done by the user. |
Are you sure? I tried the equivalent in C#:
And got a better error message:
Or:
I didn't try raw Win32 API calls though. |
So, just in case this is helpful: Colons are used by NTFS to name separate Alternate Data Streams, so if there’s a file named So it would seem to me that ENOENT would be the correct code for writing to I’m not sure the overhead of checking for multiple colons would be worth it… |
I believe it might be technically possible to provide a better error message since |
Interesting, I didn't know that. The same error message happens for other invalid characters though, such as question marks:
|
The issue here is that libuv maps The question is what it should map to instead. Would |
You could change it (major version), but before you do so, do some research into what different "libc" implementations do on windows - at least try what error the open() call in msvcrt produces when you try to create a file with an invalid name, and try cygwin too. |
A
|
Good idea. I assume you meant fopen, not open. In both of your examples, |
Thanks for reporting this issue, I had no idea that : were invalid file name characters in Windows, been debugging an Electron app for a bit now. |
E.g. when trying to create a file named "foo??". Refs: nodejs/node#8987 PR-URL: #1088 Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Should this issue remain open? |
It's going to remain an issue until libuv is upgraded to 2.x. |
Add a known_issues test for the Windows returning ENOTFOUND where EINVAL is more appropriate. This happens with various functions in the `fs` module when an invalid path is used. Refs: nodejs#8987 PR-URL: nodejs#28569 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Add a known_issues test for the Windows returning ENOTFOUND where EINVAL is more appropriate. This happens with various functions in the `fs` module when an invalid path is used. Refs: #8987 PR-URL: #28569 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
There's been no activity on this and it's been blocked indefinitely pending the update to libuv 2.x. Keeping the issue open does not benefit anyone but we also don't want to forget about it. I've added it to a Futures project board so it doesn't get lost. |
Node v6.7.0, Windows 10
To reproduce the issue:
Expected output: Some error message about the filename being invalid because it contains colons
Actual output:
The text was updated successfully, but these errors were encountered: