Skip to content

bug: x-opencode-directory header invalid on Windows Chinese path #13256

Closed

Description

@hexuansun43-dotcom

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:

  1. Create a folder with Chinese characters: C:\Users\KC\Desktop\MyFile\待办
  2. Navigate to the folder: cd C:\Users\KC\Desktop\MyFile\待办
  3. Run command: opencode
  4. 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

  1. Rename folder to English (e.g., todo) → works
  2. 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

[email protected]

OpenCode version

1.1.56

Steps to reproduce

Steps to reproduce the behavior:

  1. Create a folder with Chinese characters: C:\Users\KC\Desktop\MyFile\待办
  2. Navigate to the folder: cd C:\Users\KC\Desktop\MyFile\待办
  3. Run command: opencode
  4. See error: TypeError: Header 'x-opencode-directory' has invalid value: 'C:\Users\KC\Desktop\MyFile\待办'

Screenshot and/or share link

Image

Operating System

Windows11

Terminal

Windows PowerShell

Activity

  1. github-actions commented on Feb 12, 2026

    @github-actions
    Contributor

    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-directory HTTP 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 (using encodeURIComponent) appears viable.

    Consider consolidating these reports to avoid duplicate work.

  2. hexuansun43-dotcom commented on Feb 12, 2026

    @hexuansun43-dotcom
    Author

    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-directory HTTP header. The encodeURIComponent fix suggested in #13167 is a viable solution.

    Thanks for pointing this out!

  3. github-actions commented on Apr 14, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingwindows

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions