Image paste (Ctrl+V) fails with UTF-8 surrogate error on WSL2
Environment
- Claude Code VSCode extension: 2.1.191
- WSL2 (Linux 6.6.114 Microsoft Standard)
- Windows clipboard (screenshots from PrtSc / Snipping Tool)
Behavior
Pasting a screenshot or image via Ctrl+V into the chat input causes a 400 error with invalid Unicode / surrogate UTF-8, making the chat unusable until /clear.
Root cause (investigated in webview/index.js)
The paste handler (wr function) only intercepts clipboard items where kind === "file". On WSL2, image data from the Windows clipboard is not exposed as a kind === "file" DataTransfer item inside the VSCode webview. As a result, preventDefault() is never called, the browser's default paste behavior fires, and raw binary image data gets inserted as text into the contenteditable input. That binary contains invalid Unicode surrogate pairs, which the Anthropic API rejects with HTTP 400.
Steps to reproduce
- Run Claude Code VSCode extension on WSL2
- Take a screenshot (PrtSc or Snipping Tool) — image goes to Windows clipboard
- Click the chat input and press Ctrl+V
- Try to send the message → 400 surrogate UTF-8 error
Workaround
Save the image as a PNG file and drag it into the chat instead of pasting.
Suggested fix
In the paste handler, also handle the case where the clipboard contains image data not exposed as kind === "file" (e.g., read it via kind === "string" with an image MIME type, or use clipboardData.getData("image/png") as a fallback).
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗