Non-ASCII (Korean/CJK) characters in directory path cause "Header has invalid value" error (regression in v1.1.56) #9092

Open
opened 2026-02-16 18:11:37 -05:00 by yindo · 2 comments
Owner

Originally created by @SOPA5 on GitHub (Feb 11, 2026).

Originally assigned to: @rekram1-node on GitHub.

Bug Description

opencode crashes on startup when the working directory path contains non-ASCII characters (Korean, CJK, etc.).

This is a regression introduced between v1.1.53 and v1.1.56.

Error

TypeError: Header 'x-opencode-directory' has invalid value
    at mergeHeaders (../sdk/js/src/gen/client/utils.gen.ts:184:23)
    at mergeConfigs (../sdk/js/src/gen/client/utils.gen.ts:161:20)
    at createClient (../sdk/js/src/gen/client/client.gen.ts:21:17)
    at createOpencodeClient (../sdk/js/src/gen/client/client.gen.ts:135:10)

Root Cause

The x-opencode-directory HTTP header is set with the raw directory path string. The Web Headers.set() API only accepts Latin1 (ISO-8859-1) characters, so any path containing Korean, CJK, or other non-Latin1 characters causes a TypeError.

Reproduction

  1. Create a directory with non-ASCII characters in the path:
    mkdir C:\temp\test\한글경로\coding
    
  2. Run opencode v1.1.56 in that directory:
    cd C:\temp\test\한글경로\coding
    opencode
    
  3. Observe the TypeError crash.

Version Testing Results

Version Result
v1.1.36 Works
v1.1.49 Works
v1.1.50 Works
v1.1.53 Works
v1.1.56 Fails

Environment

  • OS: Windows 10 (Build 26200.7840)
  • opencode: v1.1.56 (installed via scoop)
  • Node: v24.13.0
  • Bun: 1.3.9

Suggested Fix

URL-encode or Base64-encode the x-opencode-directory header value before passing it to Headers.set(). For example:

// Before (broken for non-ASCII)
headers.set('x-opencode-directory', directory);

// After (safe for all characters)
headers.set('x-opencode-directory', encodeURIComponent(directory));

On the receiving end, decode with decodeURIComponent().

Workaround

Downgrade to v1.1.53:

scoop reset opencode@1.1.53
Originally created by @SOPA5 on GitHub (Feb 11, 2026). Originally assigned to: @rekram1-node on GitHub. ## Bug Description opencode crashes on startup when the working directory path contains non-ASCII characters (Korean, CJK, etc.). This is a **regression** introduced between v1.1.53 and v1.1.56. ## Error ``` TypeError: Header 'x-opencode-directory' has invalid value at mergeHeaders (../sdk/js/src/gen/client/utils.gen.ts:184:23) at mergeConfigs (../sdk/js/src/gen/client/utils.gen.ts:161:20) at createClient (../sdk/js/src/gen/client/client.gen.ts:21:17) at createOpencodeClient (../sdk/js/src/gen/client/client.gen.ts:135:10) ``` ## Root Cause The `x-opencode-directory` HTTP header is set with the raw directory path string. The Web `Headers.set()` API only accepts Latin1 (ISO-8859-1) characters, so any path containing Korean, CJK, or other non-Latin1 characters causes a `TypeError`. ## Reproduction 1. Create a directory with non-ASCII characters in the path: ``` mkdir C:\temp\test\한글경로\coding ``` 2. Run opencode v1.1.56 in that directory: ``` cd C:\temp\test\한글경로\coding opencode ``` 3. Observe the `TypeError` crash. ## Version Testing Results | Version | Result | |---------|--------| | v1.1.36 | ✅ Works | | v1.1.49 | ✅ Works | | v1.1.50 | ✅ Works | | v1.1.53 | ✅ Works | | v1.1.56 | ❌ Fails | ## Environment - **OS**: Windows 10 (Build 26200.7840) - **opencode**: v1.1.56 (installed via scoop) - **Node**: v24.13.0 - **Bun**: 1.3.9 ## Suggested Fix URL-encode or Base64-encode the `x-opencode-directory` header value before passing it to `Headers.set()`. For example: ```typescript // Before (broken for non-ASCII) headers.set('x-opencode-directory', directory); // After (safe for all characters) headers.set('x-opencode-directory', encodeURIComponent(directory)); ``` On the receiving end, decode with `decodeURIComponent()`. ## Workaround Downgrade to v1.1.53: ``` scoop reset opencode@1.1.53 ```
yindo added the windows label 2026-02-16 18:11:37 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Feb 11, 2026):


This issue appears to be a duplicate or closely related to existing reports about the same regression. Please check these issues:

  • #13087: [Crash] Crash when working directory path contains non-ASCII characters (e.g. Chinese)
  • #13098: Mac issue with Chinese characters in path (same error: x-opencode-directory)
  • #13061: Chinese/Unicode path broken since v1.1.54 - Windows Desktop
  • #13063: opencode在带有中文路径的文件下无法打开
  • #13060: Desktop on Windows: saved non-ASCII workspace paths break session/model loading
  • #13112: [BUG] Desktop app fails to load projects with Chinese characters in path

All of these appear to be related to the same root cause you've identified: the x-opencode-directory HTTP header not properly encoding non-ASCII characters in v1.1.56.

@github-actions[bot] commented on GitHub (Feb 11, 2026): --- This issue appears to be a duplicate or closely related to existing reports about the same regression. Please check these issues: - #13087: [Crash] Crash when working directory path contains non-ASCII characters (e.g. Chinese) - #13098: Mac issue with Chinese characters in path (same error: x-opencode-directory) - #13061: Chinese/Unicode path broken since v1.1.54 - Windows Desktop - #13063: opencode在带有中文路径的文件下无法打开 - #13060: Desktop on Windows: saved non-ASCII workspace paths break session/model loading - #13112: [BUG] Desktop app fails to load projects with Chinese characters in path All of these appear to be related to the same root cause you've identified: the x-opencode-directory HTTP header not properly encoding non-ASCII characters in v1.1.56.
Author
Owner

@aSidorenkoCodePPI commented on GitHub (Feb 12, 2026):

Image

Tested the below versions:

Image

Results

Version Status
v1.1.50 OK
v1.1.51 OK
v1.1.52 OK
v1.1.53 OK
v1.1.54 CRASH
v1.1.55 CRASH
v1.1.56 CRASH
v1.1.57 OK
v1.1.58 OK
v1.1.59 OK
v1.1.60 OK

@rekram1-node I think this and related issues can be closed.

@aSidorenkoCodePPI commented on GitHub (Feb 12, 2026): <img width="1115" height="628" alt="Image" src="https://github.com/user-attachments/assets/3b992998-f62e-4877-9f2e-50176f9ec5ec" /> Tested the below versions: <img width="673" height="516" alt="Image" src="https://github.com/user-attachments/assets/2e5d33f4-b7c8-4750-b654-df5789f97f12" /> ## Results | Version | Status | |---------|--------| | v1.1.50 | OK | | v1.1.51 | OK | | v1.1.52 | OK | | v1.1.53 | OK | | v1.1.54 | CRASH | | v1.1.55 | CRASH | | v1.1.56 | CRASH | | v1.1.57 | OK | | v1.1.58 | OK | | v1.1.59 | OK | | v1.1.60 | OK | @rekram1-node I think this and related issues can be closed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#9092