Skip to content

Quality: removeFileAtPath silently corrupts file tree when file not found (splice with index -1)#606

Open
kumburovicbranko682-boop wants to merge 1 commit into
chinchang:masterfrom
kumburovicbranko682-boop:contribai/improve/quality/removefileatpath-silently-corrupts-file-
Open

Quality: removeFileAtPath silently corrupts file tree when file not found (splice with index -1)#606
kumburovicbranko682-boop wants to merge 1 commit into
chinchang:masterfrom
kumburovicbranko682-boop:contribai/improve/quality/removefileatpath-silently-corrupts-file-

Conversation

@kumburovicbranko682-boop

Copy link
Copy Markdown

✨ Code Quality

Problem

When the target file does not exist at the given path, getChildFileFromName returns {index: -1, file: undefined}. The destructured index is -1, and currentFolder.splice(-1, 1) silently removes the last item in the array instead of the intended file. This is silent data corruption — the user deletes a nonexistent path and loses an unrelated file.

Severity: critical
File: src/fileUtils.js

Solution

When the target file does not exist at the given path, getChildFileFromName returns {index: -1, file: undefined}. The destructured index is -1, and currentFolder.splice(-1, 1) silently removes the last item in the array instead of the intended file. This is silent data corruption — the user deletes a nonexistent path and loses an unrelated file.

Changes

  • src/fileUtils.js (modified)

Testing

  • Existing tests pass
  • Manual review completed
  • No new warnings/errors introduced


🤖 About this PR

This pull request was generated by ContribAI, an AI agent
that helps improve open source projects. The change was:

  1. Discovered by automated code analysis
  2. Generated by AI with context-aware code generation
  3. Self-reviewed by AI quality checks

If you have questions or feedback about this PR, please comment below.
We appreciate your time reviewing this contribution!

Closes #605

…when file not found (splice with index -1)

When the target file does not exist at the given path, `getChildFileFromName` returns `{index: -1, file: undefined}`. The destructured `index` is -1, and `currentFolder.splice(-1, 1)` silently removes the **last** item in the array instead of the intended file. This is silent data corruption — the user deletes a nonexistent path and loses an unrelated file.


Affected files: fileUtils.js

Signed-off-by: kumburovicbranko682-boop <295886834+kumburovicbranko682-boop@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(fileUtils.js): removefileatpath silently corrupts file tree when file not found (splice with index -1)

1 participant