[BUG] API Error: "invalid_request_error" "The request body is not valid JSON"

Resolved 💬 27 comments Opened Jul 19, 2025 by SaptaDey Closed Jan 9, 2026

<img width="935" height="868" alt="Image" src="https://github.com/user-attachments/assets/670a3642-df71-4408-8f39-679664c3aa26" />

Environment

  • Platform: Anthropic Login
  • Login Method: Claude Pro Account
  • Claude CLI version: v1.0.56
  • Model: Sonnet 4
  • Operating System: Ubuntu 24.04
  • Terminal: Ubuntu

Bug Description

Persistant following error message despite several different edit commands

⎿ API Error: 400
{"type":"error","error":{"type":"invalid_request_error","message":"The request body
is not valid JSON: no low surrogate in string: line 1 column 42462 (char 42461)"}}

Expected Behavior

Not get the following error in midle of a very simple UI color changing task
⎿ API Error: 400
{"type":"error","error":{"type":"invalid_request_error","message":"The request body
is not valid JSON: no low surrogate in string: line 1 column 42462 (char 42461)"}}

Actual Behavior

I plot code to change the UI color of my WebApp, which is written in TypeScript
And it kept throwing the error after editing for few seconds.

View original on GitHub ↗

27 Comments

vietnguyenunicorn · 11 months ago

I got this also, do you have any quick fix?

olbo22 · 11 months ago

same bug. Please help

Dezocode · 11 months ago

Whats the fix????

AWZRD · 11 months ago

Guys! I figured it out!

When installing claude-code it's recommended you don't use sudo
So you'll have to rm -rf _your directory___ lib/node_modules/@anthropic-ai/claude-code

reinsall it using

npm install -g @anthropic-ai/claude-code
then
claude migrate-installer

trevor-the-developer · 11 months ago

I never used sudo was working then suddenly died on me with a similar error:

API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"The request body is not valid JSON: no low surrogate in string: line 1 column 360047 (char 
    360046)"}}

I had to exit CC then start again by typing claude in the project directory thankfully I was getting CC to plan everything first and document any/all actions in case similar happens.

magikMaker · 11 months ago

Any news on this? I also have this problem now

API Error: 400 {"type":"error","error":{"type":"invalid_request_
error","message":"The request body is not valid JSON: no low
surrogate in string: line 1 column 156085 (char 156084)"}}

It does seem that starting a new Claude Code session "fixes" it though

sammywachtel · 11 months ago

Same here. A workaround for me was to:
\export the session and then start a new one and say in the new one Resume the conversation in 2025-08-08-this-session-is-being-continued-from-a-previous-co.txt and let's continue with what we were in the middle of.

This picked up the conversation and got around the error. This suggests that something becomes corrupted in the session itself.

Bug Description
I keep getting the following error and I'm not sure what's causing it. API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"The request body is not valid JSON: no low surrogate in string: line 1 column 54841 (char
54840)"}}

Environment Info

  • Platform: darwin
  • Terminal: Apple_Terminal
  • Version: 1.0.71
  • Feedback ID:

Errors

[{"error":"AxiosError: Request failed with status code 403\n    at VN (file:///Users/username/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:682:1077)\n    at Unzip.J0 (file:///Users/username/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:683:9955)\n    at Unzip.emit (node:events:530:35)\n    at Unzip.emit (node:domain:489:12)\n    at endReadableNT (node:internal/streams/readable:1698:12)\n    at process.processTicksAndRejections (node:internal/process/task_queues:90:21)\n    at $B1.request (file:///Users/username/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:685:2088)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n    at async uK8 (file:///Users/username/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:2289:470)\n    at async Promise.all (index 0)\n    at async file:///Users/username/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:2275:19497","timestamp":"2025-08-08T14:48:40.786Z"}]
alexx-ftw · 11 months ago

The same just happened to me in Windows 11 with CC 1.0.72. Worked around it with the `/export` method

vinodsharma10x · 11 months ago

I encountered this exact same error today. The following solution worked for me, and I hope it will be helpful to you as well.
Solution:

Step 1 - Type /status to find your claude code Session ID. Note it.
Step 2 - CTR+C twice to exit the Claude session
Step 3 - Restart terminal (or VS Code)
Step 4 - Use one of the following options to resume your Claude session.

Type "claude --resume" (This command will list your previous Claude code conversations for you to select from.)
claude -r "session-id" (resume specific session)
claude -c (resume most recent session)

I also recorded a video to make it easy for you to follow.
https://youtu.be/lAnaIz-uaek

Malik0712 · 11 months ago

Having same issue no matter how i restart the session, whatever i type in the prompt returns with same error even after restarting session

github-actions[bot] · 11 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/5889
  2. https://github.com/anthropics/claude-code/issues/1709
  3. https://github.com/anthropics/claude-code/issues/1832

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

m3nt0l · 11 months ago

Temporar Fix:

  1. Quit claude
  2. In terminal run: rm -rf ~/.claude/cache
  3. Then run: rm -rf ~/.claude/tmp
  4. Then run: file -bi . | grep -v ascii
byliu · 11 months ago

same issue

andreasotto · 10 months ago

Any news on this? happening here too in the middle of a conversation for no clear reason. Claude developers around?

TomMaxon · 10 months ago

issue still exists as of Sep 11 2025

echoes-byte · 10 months ago

I’m experiencing the exact same issue.
The only way I can continue working is by starting a new session, as resuming or restarting the current one always fails with the same error:

API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"The request body is not valid JSON..."}}

It seems like the session itself gets corrupted, and I haven’t found any workaround other than creating a fresh session.

trevor-the-developer · 10 months ago

I have a workaround but to be honest I have not had any similar issues for a while now not since last commenting on this thread.

I suggest as you work ask CC to generate index files these are markdown files that tell it where everything is, what context file(s), where the code is, key points etc (this doc is useful to a developer as well as a jumping in point), then during your sessions when you get a pause ask it to record the session details for its future self to continue should you need to take a break.

This works relatively well for me for example I prompt like this:

Hi buddy can you enable beast mode see claude-code-warp-beast-mode.md then digest your CLAUDE.md context file and any/all documents in this solution finally understand the code base 
  see CODE_INDEX.md for reference then give me a plan of where we are and what was next on the planned sprints and tasks.

"BEAST MODE" is the infamous ChatGPT beast mode script that I adapted for Claude Code found here: LINK.

Its a little clunky but I found I was able to continue just fine most of the time especially when I have documents that capture any plans and the current plan (I plan often, execute a few times), any key points from a previous session e.g. we figured out how to do something or resolve a bug.

I have found since I keep my context sessions smaller I am not having issues (on Claude Code v1.0.113)

Anima-t3d · 10 months ago

Bug is still happening (mac Claude Code v1.0.108), /export worked thanks @sammywachtel

aalmazzo · 9 months ago

I just got the same error, even though I tried some of the recommendations from here. The only step that worked was to start a brand-new session.

This is unacceptable for such a high price point.

SamEggert · 9 months ago

This error repeatedly occurs for me when Claude Code edits files containing emojis on Debian, but I haven’t experienced it on macOS. Looking at the original bug report, it looks like they are also experiencing it on a file with Emojis on a Linux distro.

Donubu · 9 months ago

:( the same problem using macosx. Emoji based file break all.

apurvdeodhar · 9 months ago

Any solution or quick fixes folks, the issue seems to persist !!

PS : The dump workaround for me was to go back a few messages (press esc go 3-4 messages back) and restart that convo with either copy + pasted context from earlier or just start a fresh one !!!

But would be great to get this fixed !!

vibesforhumanity · 9 months ago

This is happening for me as well. Any update?

oldrich-s · 8 months ago

We get similar issue in our chatbot connected to claude api - the issue was that in the prompt we were sending snippet of csv file that contained utf-8 BOM header. After stripping the BOM header, the error disappeared.

github-actions[bot] · 7 months ago

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

github-actions[bot] · 6 months ago

This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.

github-actions[bot] · 6 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.