Repository navigation
Description
Description
Describe the bug
On Windows system, starting opencode in a directory with Chinese characters (e.g., 待办) or using default backslash path (\) triggers a TypeError for invalid x-opencode-directory header value.
To Reproduce
Steps to reproduce the behavior:
- Create a folder with Chinese characters:
C:\Users\KC\Desktop\MyFile\待办 - Navigate to the folder:
cd C:\Users\KC\Desktop\MyFile\待办 - Run command:
opencode - See error:
TypeError: Header 'x-opencode-directory' has invalid value: 'C:\Users\KC\Desktop\MyFile\待办'
Expected behavior
opencode should support Windows paths with Chinese characters and backslashes, start normally without errors.
Actual behavior
Error log:
{
"name": "UnknownError",
"data": {
"message": "TypeError: Header 'x-opencode-directory' has invalid value: 'C:\Users\KC\Desktop\MyFile\待办'\n at set (unknown)\n at mergeHeaders (../sdk/js/src/gen/client/utils.gen.ts:184:23)\n at mergeConfigs (../sdk/js/src/gen/client/utils.gen.ts:161:20)\n at createClient (../sdk/js/src/gen/client/client.gen.ts:21:17)\n at createOpencodeClient (../sdk/js/src/client.ts:28:18)\n at (src/plugin/index.ts:25:20)\n at (src/project/state.ts:22:21)\n at init2 (src/plugin/index.ts:123:25)\n at InstanceBootstrap (src/project/bootstrap.ts:19:16)\n at (src/project/instance.ts:34:23)\n at async provide (src/project/instance.ts:40:23)"
}
}
Environment
- OS: Windows 10/11
- Shell: PowerShell
- opencode version: 1.1.56
Workaround
- Rename folder to English (e.g.,
todo) → works - Use forward slash path:
opencode --directory "C:/Users/KC/Desktop/MyFile/待办"→ works
Suggested fix
The issue may be caused by:
- Missing escape for Windows backslash (
\) in HTTP header value - No handling for Chinese character encoding in path
Plugins
OpenCode version
1.1.56
Steps to reproduce
Steps to reproduce the behavior:
- Create a folder with Chinese characters:
C:\Users\KC\Desktop\MyFile\待办 - Navigate to the folder:
cd C:\Users\KC\Desktop\MyFile\待办 - Run command:
opencode - See error:
TypeError: Header 'x-opencode-directory' has invalid value: 'C:\Users\KC\Desktop\MyFile\待办'
Screenshot and/or share link
Operating System
Windows11
Terminal
Windows PowerShell
Activity
github-actions commentedon Feb 12, 2026
This issue appears to be a duplicate of existing reports about non-ASCII characters in directory paths. Please check:
These are all the same root cause: the
x-opencode-directoryHTTP header is set with raw path strings containing non-ASCII characters, violating RFC 7230 (headers must contain only visible ASCII). The suggested fix in #13167 (usingencodeURIComponent) appears viable.Consider consolidating these reports to avoid duplicate work.
hexuansun43-dotcom commentedon Feb 12, 2026
Hi,
After submitting this issue, I was informed it's a duplicate of existing reports (#13167, #13087, #13063, #6906) about non-ASCII characters in directory paths violating RFC 7230. I will close this duplicate issue and add my details to #13063 to consolidate feedback.
The root cause is confirmed: raw non-ASCII paths in the
x-opencode-directoryHTTP header. TheencodeURIComponentfix suggested in #13167 is a viable solution.Thanks for pointing this out!
github-actions commentedon Apr 14, 2026
To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.