Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

apply_patch can be applied halfway on Windows, with no undo

Closed
#242 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
30/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
rust, typescript
Domain
desktop

Research direction

Start in native/sandbox-helper/src/file_ops/windows.rs: the prepare step around lines 126-136 returns early on a missing folder without checking the new file name, and apply around lines 174-194 has no rollback. The loop in file_helper.rs (lines 88-90) and claim in apply_patch.ts (lines 209-213) are also involved. Reproduce the two patches in the issue on Windows to confirm the partial state. Done means both leave a.txt unchanged and create no files, and failures are rolled back using the before bytes.

Written by the indexing model from the issue text.

Description

bug platform: windows priority: medium severity: medium

Found in the 2026-10-09 codebase audit.

Problem

The helper's prepare (native/sandbox-helper/src/file_ops/windows.rs:126-136) returns early when a new file's folder is missing and never checks the name. apply (:174-194, loop in file_helper.rs:88-90) writes one operation at a time and stops at the first error with no rollback. claim (apply_patch.ts:209-213) dedupes new paths on the model's casing. run returns no undo when the helper throws.

Confirmed:

  1. Update File: a.txt + Add File: newdir/what?.txt fails with os error 123, but a.txt is already changed and newdir/ exists.
  2. Update File: a.txt + Add File: b.txt + Add File: B.txt fails with os error 80 after a.txt changed and b.txt was created.

Impact

The tool says "a failing patch changes nothing", but the project is half-patched and Undo isn't offered.

Fix

Validate new file names in prepare (Win32-invalid characters, reserved names) even when the folder is missing; key claim on a case-folded path on win32/darwin; roll back applied operations on failure using the before bytes.

Test

Both patches above leave a.txt unchanged and create nothing.

Dominant language
TypeScript
Stars
2
Forks
2
Avg merge
5h 28m
Merged PRs (30d)
24

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from PierrunoYT/patch

All issues in PierrunoYT/patch

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.