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

doc: deprecate non-string type in fs.symlink() #44641

Closed

Conversation

LiviaMedeiros
Copy link
Contributor

Disallows any type except for 'dir', 'file', 'junction', or undefined in fs.symlink(), fs.symlinkSync(), and fsPromises.symlink()
The implementation would be unconditional validating with validateOneOf(type, 'type', ['dir', 'file', 'junction', undefined]), i.e. throwing an error instead of defaulting to autodetection (or instead of ignoring on non-windows platforms).

Refs: #42894 (comment)

Not sure if it's worth the potential breakage. On a long run, replacing it with an object parameter (for example, { type: 'file', force: true, relative: false }) to allow additional options might make more sense.

Disallows any `type` except for `'dir'`, `'file'`, `'junction'`,
or `undefined` in `fs.symlink()`, `fs.symlinkSync()`, and
`fsPromises.symlink()`
@nodejs-github-bot nodejs-github-bot added the doc Issues and PRs related to the documentations. label Sep 14, 2022
@LiviaMedeiros LiviaMedeiros added the fs Issues and PRs related to the fs subsystem / file system. label Sep 14, 2022
Copy link
Contributor

@aduh95 aduh95 left a comment

Choose a reason for hiding this comment

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

Why not leave this validation at the FS level, or libuv? Doing it in Node.js seems weird to me, and potentially bad for forward compatibility.

@aduh95
Copy link
Contributor

aduh95 commented Sep 15, 2022

/cc @nodejs/fs

@aduh95 aduh95 added notable-change PRs with changes that should be highlighted in changelogs. deprecations Issues and PRs related to deprecations. labels Sep 15, 2022
@LiviaMedeiros
Copy link
Contributor Author

libuv receives flags (0, UV_FS_SYMLINK_DIR, UV_FS_SYMLINK_JUNCTION), the string parameter is Node.js-specific.
The current error (ERR_FS_INVALID_SYMLINK_TYPE) thrown for invalid strings is Node.js-specific as well.

@aduh95
Copy link
Contributor

aduh95 commented Sep 15, 2022

Oh so we don't need a deprecation, using an invalid string is already throwing.

@aduh95
Copy link
Contributor

aduh95 commented Sep 20, 2023

@LiviaMedeiros is #44641 (comment) correct or am I missing something?

@LiviaMedeiros
Copy link
Contributor Author

If I remember correctly, it's true for invalid strings; but any parameter with typeof ... !== 'string' is interpreted as default ('file' for API, 0 for internals and libuv).
The deprecation was specifically for non-string arguments.

@aduh95
Copy link
Contributor

aduh95 commented Sep 20, 2023

The documentation already indicates it should be a string, I don't think we need a deprecation for that. It sounds like we can tighten up the check as a semver major directly, unless there's a massive ecosystem breakage of doing so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecations Issues and PRs related to deprecations. doc Issues and PRs related to the documentations. fs Issues and PRs related to the fs subsystem / file system. notable-change PRs with changes that should be highlighted in changelogs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants