apply_patch and view_image fail with false "os error 206" (filename too long) under restricted permission profile on Windows
Open 💬 4 comments Opened Jul 8, 2026 by okki-LC369
💡 Likely answer: A maintainer (github-actions[bot], contributor)
responded on this thread — see the highlighted reply below.
codex-cli 0.142.5 (Windows, elevated sandbox)。カスタムプロファイル(:workspaceを拡張し:root=deny)下で、apply_patch・view_imageが偽の「ファイル名が長すぎる」エラーで失敗する件を報告。
- 実パス長は60〜70文字程度(Windowsの260文字上限には遠い)
- 同じファイルへのPowerShell経由アクセス(Copy-Item/Set-Content等)は同一セッションで正常成功
- パスは付与された書込み/読取り可能な範囲内(承認プロンプトなし・該当denyルールなし)
- 長いパス/短いASCIIパスどちらでも再現=パス長自体が原因ではない
- 以前の:root=read設定では正常動作していた→:root=denyへ切替後から一貫して再現
- 影響:apply_patchはシェル経由で代替可能。view_imageには代替手段がなく、この構成下ではモデルが画像を目視できない
4 Comments
English translation:
codex-cli 0.142.5 (Windows, elevated sandbox). Reporting an issue where apply_patch and view_image fail with a false "filename too long" error under a custom profile (extending :workspace and setting :root=deny).
<!-- codex-issue-translator -->
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
This may be related to a broader pattern of Windows-specific failures involving OS error 206, seen across several other issues:
apply_patchfails on Windows withCreateProcessAsUserW failed: 206for large patch payloadsapply_patchfails for large patches because the patch body is still transported via argvapply_patchfails under sandboxed default permission on WindowsThose issues attribute the failure to argv length limits for large patch bodies. However, in this issue the failure reproduces under different conditions:
view_imagefails too (a read-only tool with no patch payload at all)":root" = "deny"(previously worked fine under":root" = "read", and shell-invoked commands like PowerShell continue to work fine under the same":root" = "deny"profile)This suggests the root cause may not be specific to
apply_patch's argv-based patch transport, but something more general about how codex's native file tools (as opposed to shell-invoked commands) spawn or communicate with a sandboxed child process under restrictive permission profiles on Windows — possibly in howCreateProcessAsUserW(or an equivalent call) is invoked for these tools specifically.Environment: codex-cli 0.142.5, Windows,
[windows] sandbox = "elevated",default_permissionsprofile with":root" = "deny".Root cause identified — deterministic repro and un-repro for the false
os error 206I hit this bug on 2026-07-07 and finally isolated the trigger on 2026-07-26. Sharing because the err
or message points in the wrong direction (it cost me 19 days).
TL;DR: The false
os error 206("filename or extension too long") fromapply_patch/view_imis triggered by the combination ofage
:root = "deny"in a permission profile and a non-glob (folder)
deny_readentry nested inside a root that the profile grants"read". Neither condition alone triggers it. Actual path length is irrelevant (fails at 55 chars, works at 145 after t
he fix).
Environment
(
[windows] sandbox = "elevated"), admin-managedrequirements.tomlRepro (5 steps)
``
toml
``[permissions.restricted.filesystem]
":root" = "deny"
"C:/work/allowed" = "read"
``
toml
``[permissions.filesystem]
deny_read = ["C:/work/allowed/private_folder"]
SandboxUsers
group (visible viaicacls:(DENY)(R)on the folder plus an inherited-only(OI)(CI)(IO)(DENY)(R,GR)`).
view_imageorapply_patchany file underC:/work/allowed— even files completely outside
private_folder, with short paths → both tools fail withos error 206("filename or extension too long").
shellcommands on the same files still work.deny_readline, remove the stale DENY ACEs (`icacls "C:/work/allowed/private_folder" /remove:d ...` — note Codex does not auto-remove ACEs when the config line is removed),
restart → both tools work again. Re-adding the line re-breaks them. Fully deterministic in both dir
ections.
What does NOT trigger it (all verified)
:root = "deny"alone (with no nested non-glob deny) — tools work.deny_readentries inside the same allowed root (e.g. `"C:/work/allowed/**/*.xlsx"`) — these stamp DENY ACEs on matching files rather than an inherited folder DENY, and the tools
keep working.
Mechanism (working hypothesis — not verified in source)
The distinguishing factor on disk is an inheritable folder DENY ACE inside the allowed tree. Whe
n the native file tools walk/canonicalize paths under the allowed root and encounter that inherited
DENY, the failure appears to be mis-mapped to
ERROR_FILENAME_EXCED_RANGE(206) instead ofERROR_A(5). Genuine denials elsewhere correctly surface asCCESS_DENIED
os error 5, which is how the false 206 can be distinguished in the wild.
Impact / ask
\\?\issues. If the underlying cause can't be fixed quickly, even correcting the error mapping (206 → 5, or a specific message) would save a
lot of debugging time.
allowed read roots.