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

Inconsistent statSync().mode Behavior: Fails to Differentiate Between Non-Existent and Permission-Denied Files #57111

Open
stephane-archer opened this issue Nov 16, 2024 · 1 comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. library-io type-enhancement A request for a change that isn't a bug

Comments

@stephane-archer
Copy link

Currently, the statSync().mode API in Dart has inconsistent behavior when dealing with non-existent files and files with restricted permissions:

touch MyFile
chmod 000 ./MyFile
var mode = File("MyFile").statSync().mode; // Returns 0 as expected (no permissions). 
var mode = File("notExistingFile").statSync().mode;  
// Also returns 0, which is misleading because the file does not exist.
// Ideally, it should throw an exception to differentiate this case.  

Expected Behavior:
An exception should be thrown for non-existent files to distinguish them from files with restricted permissions.

Actual Behavior:
Both scenarios return 0 from statSync().mode, which can lead to incorrect assumptions in applications.

@dart-github-bot
Copy link
Collaborator

Summary: statSync().mode returns 0 for both non-existent and permission-denied files. This inconsistency needs a fix to throw an exception for non-existent files.

@dart-github-bot dart-github-bot added area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Nov 16, 2024
@lrhn lrhn added area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. library-io type-enhancement A request for a change that isn't a bug and removed area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. labels Nov 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. library-io type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

3 participants