Skip to content

Conversation

@LiviaMedeiros
Copy link
Member

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-botnodejs-github-bot added the doc Issues and PRs related to the documentations. label Sep 14, 2022
@LiviaMedeirosLiviaMedeiros added the fs Issues and PRs related to the fs subsystem / file system. label Sep 14, 2022
Copy link
Contributor

@aduh95aduh95 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

/cc @nodejs/fs

@aduh95aduh95 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
MemberAuthor

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

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

@aduh95
Copy link
Contributor

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

@LiviaMedeiros
Copy link
MemberAuthor

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

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 freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deprecationsIssues and PRs related to deprecations.docIssues and PRs related to the documentations.fsIssues and PRs related to the fs subsystem / file system.notable-changePRs with changes that should be highlighted in changelogs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@LiviaMedeiros@aduh95@nodejs-github-bot