Skip to content

5.3 apply_patch fails under sandboxed default permission on Windows #13574

Closed

Description

@EarzuChan

What version of the Codex App are you using (From “About Codex” dialog)?

0.108.0-alpha.8

What subscription do you have?

$200

What platform is your computer?

Microsoft Windows NT 10.0.26100.0 x64

What issue are you seeing?

This report was generated by 5.3-codex itself, and confirmed by me: It fails to apply any patches under the default permission mode, showing "Refused" on the UI. However, patches can be applied with highest permissions. Meanwhile, Codex on macOS can correctly apply patches with default permissions. Therefore, I suspect this is a bug. I conducted a test with 5.3-codex and got the following report:

Summary
When running in workspace-write (not read-only), built-in apply_patch fails for both Add File and Update File with:

  • Exit code: 1
  • Empty output

No permission/grant prompt is shown, and no actionable error message is returned.

Environment

  • Workspace: E:\c_misc\tmp\testspace
  • Mode shown: workspace-write
  • Shell not used for repro (built-in tool only)
  • Network restriction status is irrelevant for this repro

Reproduction Steps

  1. Try creating a file via apply_patch:
    • Add File: ap_test_create.txt
    • content: apply_patch create test
  2. Try updating an existing file via apply_patch:
    • Update File: daipaibulaodi.ja.md
    • replace first line with another line
  3. (Control) Try deleting the not-created file:
    • Delete File: ap_test_create.txt

Expected Behavior

  • In workspace-write, Add File and Update File should succeed in workspace paths.
  • If blocked, the tool should return a clear permission/validation error.

Actual Behavior

  • Add File: Exit code 1, empty output
  • Update File: Exit code 1, empty output
  • Delete File: returns a normal verification error (file not found), indicating path checks still work

Raw Observations

  • No escalation/permission prompt appeared for failed Add/Update.
  • Failures are reproducible and opaque (no stderr/body), which makes diagnosis difficult.

Impact

  • Prevents basic file creation/editing through built-in tool even in non-read-only mode.
  • Blocks normal coding workflow and automated patching.

What steps can reproduce the bug?

  1. Create a new folder and add a file with a few lines of content

  2. Ask 5.3-codex to modify the file under the default permission mode

  3. Observe the "Refused" error on the UI

What is the expected behavior?

The file should be edited properly

Additional information

No response

Activity

  1. added
    app
    on Mar 5, 2026
  2. added
    bug
    windows-os
    sandbox
    tool-calls
    on Mar 5, 2026
  3. github-actions commented on Mar 5, 2026

    @github-actions
    Contributor
  4. adxptived commented on Mar 5, 2026

    @adxptived

    the same

  5. doublemover commented on Mar 5, 2026

    @doublemover

    Mine's asking for permissons to do anything constantly, doesn't matter if I give it full access, default, etc. It's impossible to use! It also does not remember any "for this session" choice, and neither do sub agents. It's entirely unsuitable for work

  6. removed
    tool-calls
    sandbox
    on Mar 5, 2026
  7. FylmTM commented on Mar 5, 2026

    @FylmTM

    Same issue. GPT-5.4 debugged itself and created bug report:

    Version:

    • Codex Desktop CLI version: 0.108.0-alpha.8
    • Desktop app build: 26.304.38.0

    Issue:
    apply_patch always fails in Desktop with exit_code: 1 and empty output. No file changes are made.

    Debugging results:

    • apply_patch create: failed
    • apply_patch update on existing file: failed
    • Restarting Desktop: no change
    • Shell file create/modify/delete in the same workspace: succeeded
    • Codex CLI in the same workspace: apply_patch succeeded

    Conclusion:
    This looks Desktop-specific, not a workspace permission issue, not general file I/O, and not a basic patch syntax problem.

  8. skbtwiz commented on Mar 5, 2026

    @skbtwiz

    I am facing this same issue too, switching to Full Access mode worked for me, though this is not desirable. When I try to submit feedback using /feedback it doesn't work and gives me an error saying feedback could not be submitted.

  9. yaboijbigs commented on Mar 5, 2026

    @yaboijbigs

    Using Codex windows app. GPT-5.4 with Full Access and Extra High Reasoning can't use the apply_patch tool and keeps saying it is failing with exit code 1. Here is the thread_id: 019cc04f-565c-7543-a0ff-9424111927d9

  10. AriMKatz commented on Mar 5, 2026

    @AriMKatz

    same issue. Codex told me to say this:

    I can confirm the same issue, and I have a likely root-cause detail.

    On my machine, apply_patch fails with exit code 1 and no useful stderr, but the generated apply_patch.bat points to:

    C:\Program Files\WindowsApps\OpenAI.Codex_26.305.950.0_x64__2p2nqsd0c76g0\app\resources\codex.exe

    Directly invoking that wrapper/target from PowerShell returns:

    Access is denied.

    As a control, I found an older generated wrapper on the same machine that points to the npm-installed vendored Codex binary under C:\Users\arika\AppData\Roaming\npm\node_modules\@openai\codex\..., and that launcher works far enough to parse --codex-run-as-apply-patch normally instead of failing at launch.

    This machine has both the packaged Codex app and the npm Codex CLI installed, so this may be a Windows launcher-selection bug when both installs are present.

  11. siddhantparadox commented on Mar 6, 2026

    @siddhantparadox

    apply_patch works in native codex CLI on this machine, but fails in the Codex Windows app under sandboxed modes. Device context: Lenovo model 83F5, Windows 10.0.26200.0, CPU Intel(R) Core(TM) Ultra 9 275HX, RAM 33,752,997,888 bytes (~31.4 GB), native PowerShell environment, repo on local Windows filesystem. In the app, [features] apply_patch_freeform = true is enabled. Repro is a trivial patch such as:

    *** Begin Patch
    *** Add File: smoke.txt
    +hello
    *** End Patch

    A trivial update to an existing file also fails. In the Codex Windows app, every apply_patch invocation fails immediately with exit code 1 and no diagnostic output. I confirmed this is not a patch-format or path issue: absolute path, relative path, Add File, and Update File variants all fail. It also fails in sandboxed configuration with: approval_policy = "never", sandbox_mode = "workspace-write", [sandbox_workspace_write] network_access = true, [windows] sandbox = "elevated", and features.unified_exec = true. It succeeds only in Full access / danger-full-access. Control case: native codex CLI using the same machine, same repo, and same config can apply patches successfully. That strongly suggests the issue is specific to the Codex Windows app’s sandboxed apply_patch path, likely in the native Windows workspace-write sandbox/integration rather than config, approvals, or patch content.`

  12. 17 remaining items

  13. etraut-openai commented on Mar 9, 2026

    @etraut-openai
    Contributor

    @ningjiaen123, we don't release on a fixed schedule, but we generally publish two or three releases each week. That means we should have a new release out in the next day or two.

  14. YourNeighborZ commented on Mar 9, 2026

    @YourNeighborZ

    IGNORE - diagnostic read attempt by assistant; please disregard.

  15. NESTOWL commented on Mar 10, 2026

    @NESTOWL
    Image same problem
  16. ribber commented on Mar 10, 2026

    @ribber

    same problem

  17. apuppy commented on Mar 10, 2026

    @apuppy

    Same issue on the Windows Codex app.

    Image

    I want to know why this happened and how to deal with this issue.

  18. bLightZP commented on Mar 10, 2026

    @bLightZP

    Same here, codex wrote the report:

    Bug Report
    apply_patch fails consistently on Windows Codex desktop, even for trivial add-file patches in a writable workspace.

    Environment

    • App: Codex desktop
    • Version: OpenAI.Codex_26.306.996.0_x64
    • OS: Windows
    • Workspace: C:\Git\Game
    • Sandbox mode: workspace-write

    What I tested

    1. Tried a trivial patch:
    *** Begin Patch
    *** Add File: tmp/apply_patch_probe.txt
    +probe
    *** End Patch
    1. Result: apply_patch returned exit code 1
    2. No file was created
    3. No useful error text was returned

    Why this looks like a Codex bug

    • The workspace is writable
    • Direct shell-based writes work
    • Local Git commit works
    • Creating/editing files via PowerShell works
    • The repo now has a valid HEAD and tracked files
    • An equivalent Git patch passes:
    git apply --check tmp\apply_patch_git_probe.diff

    So patch content is valid, and filesystem permissions are not the issue.

    Additional observations

    • Restarting Codex did not fix apply_patch

    Expected

    • apply_patch should create or modify files in the writable workspace

    Actual

    • apply_patch fails immediately with exit code 1 and no actionable error output
  19. etraut-openai commented on Mar 10, 2026

    @etraut-openai
    Contributor

    Thanks for the bug report. This is a known issue. See #14196. We already have a fix in place, and a new version should be out shortly.

  20. jpakkanen commented on Mar 11, 2026

    @jpakkanen

    If anyone is too impatient to wait for a fix, a workaround for this would be to grant read access for your logged in user in ACL of folder
    C:\Program Files\WindowsApps\OpenAI.Codex_xxxxx (xxxxx being the version number).

    Both rg.exe and apply_patch started working after I did this.

  21. AmazingTurtle commented on Mar 26, 2026

    @AmazingTurtle

    I am suddenly seeing the same issue on codex 0.116. It started happening yesterday, out of nowhere, without me doing an update. I was surprised how the sandbox can suddenly misbehave.

  22. balex25 commented on Mar 27, 2026

    @balex25

    Still no fixed, files with over 1k lines always get rejected!

  23. xiaoliziawa commented on Mar 28, 2026

    @xiaoliziawa

    This serious issue still persists in the latest version of Codex! I've lost all patience. Every time it fails, it clears my files! Then Codex starts to recover bit by bit. Isn't this a waste of my tokens?

  24. devcll commented on Mar 30, 2026

    @devcll

    Same issues on codex cli on linux.
    The codex cli version is 0.117.0.

    Image Image
  25. AmazingTurtle commented on Mar 31, 2026

    @AmazingTurtle

    @etraut-openai have you noticed that there is a regression? Even on a fresh and clean windows 11 install I frequently see "Failed to apply patch", only giving it Full Access helps. Other than that, most of the time it works around with powershell CLI tools to apply the changes but only after discovering that apply_patch failed; costs lots of tokens and time

  26. etraut-openai commented on Mar 31, 2026

    @etraut-openai
    Contributor

    @AmazingTurtle, this issue was fixed and closed a few weeks ago. If you're seeing a similar behavior or believe that there's a regression, please open a new bug report with details requested in the bug template.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    appbugwindows-os

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions