Skip to content

fs: fix parentPath returned from getDirent() when type is UV_DIRENT_UNKNOWN - #55553

Merged
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
LiviaMedeiros:fs-utils-getdirent-parentpath
Nov 16, 2024
Merged

fs: fix parentPath returned from getDirent() when type is UV_DIRENT_UNKNOWN#55553
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
LiviaMedeiros:fs-utils-getdirent-parentpath

Conversation

@LiviaMedeiros

Copy link
Copy Markdown
Member

The parentPath must be a path to the parent directory rather than path to the file itself.

/cc @Ethan-Arrowood @nodejs/fs

@nodejs-github-botnodejs-github-bot added fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run. labels Oct 26, 2024
@codecov

codecovBot commented Oct 26, 2024

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.42%. Comparing base (b02cd41) to head (9613c19).
Report is 8 commits behind head on main.

Additional details and impacted files
@@ Coverage Diff @@## main #55553 +/- ##
==========================================
- Coverage 88.42% 88.42% -0.01% 
==========================================
Files 654 654 Lines 187852 187852 Branches 36134 36135 +1 ==========================================
- Hits 166102 166101 -1 - Misses 14989 14991 +2 + Partials 6761 6760 -1 
Files with missing linesCoverage Δ
lib/internal/fs/utils.js99.69% <100.00%> (ø)

... and 35 files with indirect coverage changes

@LiviaMedeirosLiviaMedeiros added the request-ci Add this label to start a Jenkins CI on a PR. label Oct 26, 2024
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Oct 26, 2024
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Comment threadtest/parallel/test-fs-utils-get-dirents.js Outdated
@aduh95aduh95 added the blocked PRs that are blocked by other issues or PRs. label Oct 26, 2024
@aduh95

Copy link
Copy Markdown
Contributor

Let's wait for #55548 to land first: since there's no other test failure, it seems plausible that this change does not have any impact on the public API, it might also be due to a lack of coverage, so better safe than sorry.

@LiviaMedeiros

Copy link
Copy Markdown
MemberAuthor

This is not directly connected to the deprecated .path property. This PR fixes .parentPath, while .path just happens to return same value.
AFAICT this issue is facing public API, but it's hard to reproduce: it must be withFileTypes: true, it must be async, and most importantly, libuv must report UV_DIRENT_UNKNOWN. I have no idea how to robustly make it return UV_DIRENT_UNKNOWN type (assigning invalid type using debugfs didn't work for me). It also explains why this bug was never caught: if someone encountered corrupted files, they probably had more important and urgent problems to investigate than wrong .parentPath value.

If anyone knows how to test this on CI without exposing internals, I'd be happy to increase coverage here.

Landing this after #55548 (which is semver-major and will change tests for .path property) is likely to make backporting this PR to previous release lines necessary. But given that the bug is hard to encounter, and that test in #55547 is rewritten using sync call and can be landed without this, I'm fine with it.

@aduh95

Copy link
Copy Markdown
Contributor

#55548 […] will change tests for .path property

It should remove them yes

Landing this after #55548 […] is likely to make backporting this PR to previous release lines necessary

Hum no, I would say we should not backport it, or at least not unless we find a way to not interfere with the .path property

1 similar comment
@aduh95

Copy link
Copy Markdown
Contributor

#55548 […] will change tests for .path property

It should remove them yes

Landing this after #55548 […] is likely to make backporting this PR to previous release lines necessary

Hum no, I would say we should not backport it, or at least not unless we find a way to not interfere with the .path property

@LiviaMedeiros
LiviaMedeirosforce-pushed the fs-utils-getdirent-parentpath branch from 063c168 to 9613c19CompareNovember 15, 2024 11:04
@LiviaMedeirosLiviaMedeiros added dont-land-on-v18.x dont-land-on-v22.x PRs that should not land on the v22.x-staging branch and should not be released in v22.x. and removed blocked PRs that are blocked by other issues or PRs. labels Nov 15, 2024
@LiviaMedeiros

Copy link
Copy Markdown
MemberAuthor

Rebased on top of #55548 ( semver-majorPRs that contain breaking changes and should be released in the next major version. ), hence the dont-land labels.

@aduh95aduh95 added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Nov 15, 2024
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 15, 2024
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@aduh95aduh95 added the commit-queue Add this label to land a pull request using GitHub Actions. label Nov 16, 2024
@nodejs-github-botnodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Nov 16, 2024
@nodejs-github-bot
nodejs-github-bot merged commit c91ce21 into nodejs:mainNov 16, 2024
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in c91ce21

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.dont-land-on-v22.xPRs that should not land on the v22.x-staging branch and should not be released in v22.x.fsIssues and PRs related to the fs subsystem / file system.needs-ciPRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@LiviaMedeiros@nodejs-github-bot@aduh95