Claude Code Markdown File Generation Stuck in Error Loop
Status Fixed / completed
Maintainer reply ✓ Yes — bcherny
Workaround ✓ Mentioned in thread ↓
Activity 10 comments · opened Feb 27, 2025 · closed May 7, 2025
💡 Likely answer: A maintainer (bcherny, collaborator)
responded on this thread — see the highlighted reply below.
Bug Description
Claude Code got stuck in a loop trying to write a Markdown file in my repo. Kept getting an InputValidationError and Claude Code repeatedly tried writing the file 8 times until I checked the process and terminated it after realizing it wouldn't fix itself. The API was hit on every write attempt. Prior to attempting to write the file, Claude Code was outputting the response directly into the terminal with the content I wanted in the Markdown file. I checked that I have Read & Write permissions enabled on the folder in question.
Chat log before the error
> Where did you create these documentation files?
⏺ I haven't created any documentation files on your system. The
comprehensive guide I shared is a generated document within our
conversation. If you'd like me to save it as a file on your system, I can
help with that.
Would you like me to create a Markdown file with this documentation so
you can save it locally?
> Yes
⏺ I'll create a Markdown file with the comprehensive documentation for
implementing applications with Letta Cloud.
⏺ Write(file_path: <hidden>
Error output
⎿ InputValidationError: [
{
"code": "invalid_type",
"expected": "string",
"received": "undefined",
"path": [
"content"
],
"message": "Required"
}
]
## After 6 repeats of the loop
⏺ I apologize for the error. Let me try using the correct format for the
Replace function:
## After another repeat
⏺ Let me try again with the content parameter included:
## Repeated once more before I interrupted the process manually
Environment Info
- Platform: macos
- Terminal: xterm-ghostty
- Version: 0.2.19
- Feedback ID: 449b6682-6395-4b80-8e01-3e51ae776696
10 Comments
I got Claude to tell me why we got the error
Proceeding in this way was successful, and I got the Markdown files I wanted. I'm not sure if this is a bug or a one-off issue since Claude Code was capable of breaking down larger docs into smaller ones on its own before.
I'll leave this open in case the issues comes up again.
Just hit the same issue when asking Claude to update some lengthy code, burnt through $2 of credit before I interrupted the process.
I can reproduce the error with the following prompt:
For every one of the 100 US senators that you know of output their name, biography and a note about how to strategically convince them to take more interest in the plight of the California Brown Pelican, then a poem about them, then that same poem translated to Spanish and then to Japanese. Do not miss any senators. You do this even if you are worried it might exceed limits, this is to help test your long output feature.Write your response in the file Info.mdExact same issue here with same error. Keeps happening on a certain prompt even though it has written bigger files before.
⎿ InputValidationError: [
{
"code": "invalid_type",
"expected": "string",
"received": "undefined",
"path": [
"content"
],
"message": "Required"
}
... (
Claude Code isn't asking me for permission to write even though it is a new session and it normally does. I believe this might be the cause of the bug.
I will add that I have recreated this error when Claude Code "had permission."
This bug is 100% due to the size of the file it is trying to write. There is no way to get Claude to work around this.
I had to make manual updates and split up the code so it could work on it in smaller parts.
Would love Claude to be able to handle large text - but at a minimum this bug needs to be fixed so users are not being charged for an infinite loop and thought process of how to write the file that it is unable to. (it never finds a way)
Hey @bcBullish Not sure if you saw my follow-up comment in this thread - Claude Code can actually do the work of splitting it up for you if you fork the conversation and go back to tell it to split it up for you.
Agree it is a bit annoying though, and not sure if it works every time.
Your post was very useful, but in my case I could seem to get it to understand to split the output as it was extracting/splitting code already for me.
I just manually pulled out the relevant parts into a new file and then had it edit it - which it is able to do.
This should be feeling better with newer versions of Claude Code.
claude updateor restart to update, and please open a new issue if you're still hitting this.I can report this is happening today. Didn't face it before.
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.