claude-code-lsps icon indicating copy to clipboard operation
claude-code-lsps copied to clipboard

[ZLS] Claude Code sends malformed Windows file URIs causing InvalidParams error

Open K4leri opened this issue 10 months ago • 1 comments

Plugin Information

Plugin name: zls Plugin version: 1.0.0 (from boostvolt/claude-code-lsps)

Environment

Claude Code version: 2.0.74+ Operating System: Windows 11 LSP server version: ZLS 0.15.1

Checklist

  • [x] I am using Claude Code v2.1.0 or later (LSP is broken in v2.0.69-v2.0.x)
  • [x] I checked the Plugins tab in Claude Code (/plugin) for errors
  • [x] I verified the LSP server is installed according to Manual Installation instructions
  • [x] I verified the LSP binary is in my PATH
  • [x] I checked Claude Code logs at ~/.claude/debug/

Description

Claude Code on Windows sends incorrectly formatted file URIs to ZLS, causing error.InvalidParams during LSP initialization.

Claude Code sends: file://E:\Projects\path\to\project

Correct format (RFC 8089): file:///E:/Projects/path/to/project

Two issues:

  1. Missing third slash (file:// → file:///)
  2. Backslashes instead of forward slashes

Note: This is a bug in Claude Code's LSP client, not in the plugin itself.

Steps to Reproduce

  1. Install zls plugin on Windows
  2. Open any .zig file
  3. LSP fails to initialize with InvalidParams

Expected Behavior

ZLS should initialize successfully and provide LSP features (hover, go to definition, etc.)

Actual Behavior

ZLS fails with error.InvalidParams because it cannot parse the malformed URI.

Error Messages

From ~/.claude/debug/: [DEBUG] [LSP PROTOCOL plugin:zls:zig] Sending request 'initialize - (0)'.

From %LOCALAPPDATA%\Temp\zls\zls.log: info ( main ): Starting ZLS 0.15.1 @ 'C:\tools\zls\zls.exe' error (server): failed to process request-0-initialize: error.InvalidParams

Initialize request captured (showing malformed URI):

{
  "workspaceFolders": [{"uri": "file://E:\\Projects\\navMesh\\zigServer", "name": "zigServer"}],
  "rootUri": "file://E:\\Projects\\navMesh\\zigServer"
}

Workaround

Created a Python proxy that intercepts and fixes URIs before forwarding to ZLS:

  def fix_uri(uri):
      """Fix Windows file:// URIs to proper format"""
      if uri.startswith("file://") and not uri.startswith("file:///"):
          path = uri[7:]
          path = path.replace("\\", "/")
          return "file:///" + path
      return uri

Full proxy uses binary mode for correct Content-Length handling.

Modified .lsp.json:

{
  "zig": {
    "command": "python",
    "args": ["C:\\tools\\zls\\zls_proxy.py"]
  }
}

Additional Context

  • Same ZLS works correctly with Zed editor (which sends proper URIs)
  • This likely affects other LSP servers on Windows that strictly validate URIs
  • The fix should be in Claude Code's LSP client, not individual plugins

K4leri avatar Jan 10 '26 02:01 K4leri

This is a Claude Code client bug, not fixable in the plugin. Please report it at https://github.com/anthropics/claude-code/issues.

boostvolt avatar Jan 16 '26 22:01 boostvolt