[PR #13131] fix: encode non-ASCII directory paths in v1 SDK HTTP headers #14527

Closed
opened 2026-02-16 18:19:18 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/13131

State: closed
Merged: Yes


What does this PR do?

Fixes #13023

#11344 added directory: Instance.directory to the plugin client, but the v1 SDK (packages/sdk/js/src/client.ts) sends the raw path as the x-opencode-directory header.

Headers.set() rejects non-ASCII characters per the Fetch standard, so any project path with Chinese/Japanese/Korean characters throws a TypeError, breaking all project functionality.

This applies the same encodeURIComponent fix already in the v2 SDK (#7145) to the v1 SDK.

How did you verify your code works?

Reproduced the bug by running opencode ~/path/测试中文路径 — got TypeError: Header 'x-opencode-directory' has invalid value. After the fix, bun run dev ~/path/测试中文路径 starts normally with no errors.

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/13131 **State:** closed **Merged:** Yes --- ### What does this PR do? Fixes #13023 #11344 added `directory: Instance.directory` to the plugin client, but the v1 SDK (`packages/sdk/js/src/client.ts`) sends the raw path as the `x-opencode-directory` header. `Headers.set()` rejects non-ASCII characters per the Fetch standard, so any project path with Chinese/Japanese/Korean characters throws a TypeError, breaking all project functionality. This applies the same `encodeURIComponent` fix already in the v2 SDK (#7145) to the v1 SDK. ### How did you verify your code works? Reproduced the bug by running `opencode ~/path/测试中文路径` — got `TypeError: Header 'x-opencode-directory' has invalid value`. After the fix, `bun run dev ~/path/测试中文路径` starts normally with no errors.
yindo added the pull-request label 2026-02-16 18:19:18 -05:00
yindo closed this issue 2026-02-16 18:19:19 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14527