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

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

Merged

Conversation

LiviaMedeiros
Copy link
Contributor

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

/cc @Ethan-Arrowood @nodejs/fs

@nodejs-github-bot nodejs-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
Copy link

codecov bot commented Oct 26, 2024

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 lines Coverage Δ
lib/internal/fs/utils.js 99.69% <100.00%> (ø)

... and 35 files with indirect coverage changes

@LiviaMedeiros LiviaMedeiros added the request-ci Add this label to start a Jenkins CI on a PR. label Oct 26, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Oct 26, 2024
@nodejs-github-bot
Copy link
Collaborator

@aduh95 aduh95 added the blocked PRs that are blocked by other issues or PRs. label Oct 26, 2024
@aduh95
Copy link
Contributor

aduh95 commented Oct 26, 2024

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
Contributor Author

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
Contributor

aduh95 commented Oct 26, 2024

#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
Contributor

aduh95 commented Oct 26, 2024

#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 LiviaMedeiros force-pushed the fs-utils-getdirent-parentpath branch from 063c168 to 9613c19 Compare November 15, 2024 11:04
@LiviaMedeiros LiviaMedeiros added dont-land-on-v18.x PRs that should not land on the v18.x-staging branch and should not be released in v18.x. dont-land-on-v20.x PRs that should not land on the v20.x-staging branch and should not be released in v20.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. dont-land-on-v23.x PRs that should not land on the v23.x-staging branch and should not be released in v23.x. and removed blocked PRs that are blocked by other issues or PRs. labels Nov 15, 2024
@LiviaMedeiros
Copy link
Contributor Author

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

@aduh95 aduh95 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-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 15, 2024
@nodejs-github-bot
Copy link
Collaborator

@aduh95 aduh95 added the commit-queue Add this label to land a pull request using GitHub Actions. label Nov 16, 2024
@nodejs-github-bot nodejs-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:main Nov 16, 2024
79 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in c91ce21

tpoisseau pushed a commit to tpoisseau/node that referenced this pull request Nov 21, 2024
PR-URL: nodejs#55553
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Ceres6 pushed a commit to Ceres6/node that referenced this pull request Nov 26, 2024
PR-URL: nodejs#55553
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. dont-land-on-v18.x PRs that should not land on the v18.x-staging branch and should not be released in v18.x. dont-land-on-v20.x PRs that should not land on the v20.x-staging branch and should not be released in v20.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. dont-land-on-v23.x PRs that should not land on the v23.x-staging branch and should not be released in v23.x. fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants