[BUG] Attaching/pasting an image fails with 400 ... str is not valid UTF-8: surrogates not allowed

Open 💬 7 comments Opened Jun 20, 2026 by GuiAmaral85

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Whenever I attach or paste an image into the Claude Code chat, the request fails with:
API Error: 400 The request body is not valid JSON: str is not valid UTF-8: surrogates not allowed: line 1 column 1 (char 0)
This happens with any image, including fresh screenshots saved to the Desktop — so it is not a corrupted file. The error is reproducible across multiple different projects and has occurred consistently over several days. It looks like the client-side image-attachment encoding path is producing invalid UTF-8 (lone/unpaired surrogates) in the JSON request body.

Claude Code running inside the Claude Desktop app for Mac
App version: 1.14271.0
macOS (Apple Silicon)

What Should Happen?

The image is encoded correctly (base64 image block) and the request succeeds.

Error Messages/Logs

API Error: 400 The request body is not valid JSON: str is not valid UTF-8: surrogates not allowed: line 1 column 1 (char 0)

Steps to Reproduce

Open Claude Code inside the Mac desktop app.
Take a screenshot and either paste it (Cmd+V) or attach the saved PNG file.
Send the message.
The request fails with the 400 ... surrogates not allowed error.

Claude Model

Not sure / Multiple models

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

1.14271.0 (c8f4d8) 2026-06-18T05:47:57.000Z

Platform

Other

Operating System

macOS

Terminal/Shell

Other

Additional Information

_No response_

View original on GitHub ↗

This issue has 7 comments on GitHub. Read the full discussion on GitHub ↗