PatchTool: percent-encoded paths (file paths with spaces) trigger ENOENT #566

Closed
opened 2026-02-16 17:27:22 -05:00 by yindo · 0 comments
Owner

Originally created by @samhains on GitHub (Jul 8, 2025).

Originally assigned to: @thdxr on GitHub.

<html><head></head>

🐞 Description

Any file stored inside a directory whose name contains a space—for example
Research Journals/2025-07-08.md—cannot be accessed or updated through OpenCode.
Whether the file is referenced in a patch header or via an @ mention in chat, the request fails with:

400 Bad Request
{
  "name": "UnknownError",
  "data": {
    "message": "Error: ENOENT: no such file or directory, open '/Users/.../Research%20Journals/2025-07-08.md'"
  }
}

The %20 shows that the path is still URL-encoded when it reaches the filesystem, so Node throws ENOENT.


🔬 Steps to reproduce

  1. Create a file at
    ~/Documents/Notes/Research Journals/test.md.

  2. In OpenCode chat, type something like

    Could you update @Research Journals/test.md?
    

    or send a patch that begins with

    *** Update File: Research%20Journals/test.md
    
  3. The server responds with 400 and logs the ENOENT error above.


Expected behaviour

Requests that target paths with spaces succeed; the path shown in logs is the decoded version (Research Journals/test.md).

Actual behaviour

The path remains percent-encoded (Research%20Journals/test.md) all the way to fs.open(), resulting in ENOENT.


🌎 Environment

Component Version
OpenCode main @ f84c8fe (2025-07-09)
Runtime Bun 1.1.4 / Node 20.15.0
OS macOS 14.5 (APFS)

📝 Notes

  • Happens with both PATCH requests and simple @file references in chat.

  • Moving the note to a directory without spaces (or symlinking) avoids the error, but that’s only a temporary workaround.

</html>
Originally created by @samhains on GitHub (Jul 8, 2025). Originally assigned to: @thdxr on GitHub. <html><head></head><body> <h2>🐞 Description</h2> <p>Any file stored inside a directory whose name contains a space—for example<br> <code inline="">Research Journals/2025-07-08.md</code>—cannot be accessed or updated through OpenCode.<br> Whether the file is referenced in a patch header <strong>or via an <code inline="">@</code> mention in chat</strong>, the request fails with:</p> <pre><code>400 Bad Request { "name": "UnknownError", "data": { "message": "Error: ENOENT: no such file or directory, open '/Users/.../Research%20Journals/2025-07-08.md'" } } </code></pre> <p>The <code inline="">%20</code> shows that the path is still URL-encoded when it reaches the filesystem, so Node throws <code inline="">ENOENT</code>.</p> <hr> <h2>🔬 Steps to reproduce</h2> <ol> <li> <p>Create a file at<br> <code inline="">~/Documents/Notes/Research Journals/test.md</code>.</p> </li> <li> <p>In OpenCode chat, type something like</p> <pre><code class="language-text">Could you update @Research Journals/test.md? </code></pre> <p><strong>or</strong> send a patch that begins with</p> <pre><code>*** Update File: Research%20Journals/test.md </code></pre> </li> <li> <p>The server responds with <strong>400</strong> and logs the <code inline="">ENOENT</code> error above.</p> </li> </ol> <hr> <h2>✅ Expected behaviour</h2> <p>Requests that target paths with spaces succeed; the path shown in logs is the decoded version (<code inline="">Research Journals/test.md</code>).</p> <h2>❌ Actual behaviour</h2> <p>The path remains percent-encoded (<code inline="">Research%20Journals/test.md</code>) all the way to <code inline="">fs.open()</code>, resulting in <code inline="">ENOENT</code>.</p> <hr> <h2>🌎 Environment</h2> Component | Version -- | -- OpenCode | main @ f84c8fe (2025-07-09) Runtime | Bun 1.1.4 / Node 20.15.0 OS | macOS 14.5 (APFS) <hr> <h3>📝 Notes</h3> <ul> <li> <p>Happens with both <strong>PATCH</strong> requests and simple <code inline="">@file</code> references in chat.</p> </li> <li> <p>Moving the note to a directory without spaces (or symlinking) avoids the error, but that’s only a temporary workaround.</p> </li> </ul> </body></html>
yindo closed this issue 2026-02-16 17:27:22 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#566