opencode icon indicating copy to clipboard operation
opencode copied to clipboard

[BUG]: POSIX server resolves foreign Windows directory hints against its cwd

Open romanilyin opened this issue 5 months ago • 1 comments

Description

On a Linux/WSL server, a request directory such as C:\Work\Repo or a Windows UNC path can reach instance loading and be treated as a relative path. The value is then resolved under the server cwd, producing a mangled directory and a later 500 or misleading tool error.

The request boundary should consume query/header encoding once, detect foreign rooted syntax before InstanceStore.load, and return a structured 400 explaining that the server expects a native POSIX/WSL path.

This is only the server-side validation and diagnostic fix. It does not make Desktop preserve /mnt/c/...; that remains the client-side part of #30895.

OpenCode version

Current dev / 1.17.11

Steps to reproduce

  1. Start opencode serve on Linux or WSL.
  2. Request:
GET /session?directory=C%3A%5CWork%5CRepo
  1. Observe that the path is resolved under the server cwd and fails later instead of being rejected at the request boundary.

The same class of failure can be reproduced with a UNC directory hint such as:

\\wsl.localhost\Ubuntu\home\user\repo

Expected behavior

The server returns a structured HTTP 400 before instance creation and explains that a server-native POSIX/WSL path is required.

Operating System

Linux or Windows 11 with WSL2

Terminal

Any HTTP client, or OpenCode Desktop connected to a WSL-hosted server

romanilyin avatar Jun 27 '26 19:06 romanilyin

This issue might be a duplicate of existing issues. Please check:

  • #19473: Desktop App sends UNC paths to WSL-hosted server, causing path mangling and tool failures — describes the same root cause (Windows UNC/backslash paths resolved against server cwd on Linux/WSL) with both server-side and client-side fix suggestions

If your issue is specifically scoped to the server-side HTTP 400 validation fix (as a subset of #19473's suggested fixes), please clarify that distinction in the issue or consider contributing the fix directly to the existing tracking issue.

github-actions[bot] avatar Jun 27 '26 19:06 github-actions[bot]