apply_patch drops trailing spaces from filenames
Maintainers usually reply within 1 day
@akhil9tiet is already working on this.
Since Oct 12, 2026.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 75/100
Research direction
Start by locating the apply_patch parser that reads *** Add File headers; the issue says the parsing code remains on main at commit a9b0815167c27ab13719dd12d13b63e02b70d221. Reproduce the issue on Linux with a filename ending in a space, then trace how the header becomes a path. Done when the patch writes to the filename with its trailing space and leaves the similarly named file unchanged.
Written by the indexing model from the issue text.
Description
What issue are you seeing?
This is a minor edge case, but Linux supports filenames ending in a space. Codex's apply_patch silently removes that space and writes to a different file. Gemini CLI and OpenCode handle the same filename correctly with their write tools.
Observed on Linux at Codex commit ca466061d64f0b44f416135c7fd06aa7af850bbc. The same parsing code remains on main at a9b0815167c27ab13719dd12d13b63e02b70d221.
What steps can reproduce the bug?
Create a file whose name ends in one space:
printf 'old\n' > 'notes.txt '
Call apply_patch with this patch. The Add File header must have one space immediately after notes.txt:
*** Begin Patch
*** Add File: notes.txt
+hello
*** End Patch
Expected: write hello\n to notes.txt .
Actual: Codex reports success adding notes.txt, creates that file with hello\n, and leaves notes.txt unchanged. This simplified reproduction follows the same code path as the recorded test, which used zu.log .
What is the expected behavior?
See above
Additional information
No response
- Dominant language
- Rust
- Stars
- 128k
- Forks
- 20.1k
- Avg merge
- 1m
- Merged PRs (30d)
- 994
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from openai/codex
-
documentation
Difficulty 1/5 Under an hour Newbie friendliness 86/100
Maintainers usually reply within 1 day
-
bug CLI TUI
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
openai/codex#53227 · 1 comment ·
Maintainers usually reply within 1 day
-
enhancement extension
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
documentation mcp
Difficulty 1/5 Under an hour Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
app-server CLI enhancement windows-os
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
extendr/extendr.github.io#134 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
bgreenwell/xleak#90 · 1 reaction ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
cloudflare/boring#530 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
project-robius/robrix#1154 ·
Maintainers usually reply within 1 day