[BUG] `Failed to authenticate. API Error: 401 Invalid authentication credentials` and THEN: `Claude configuration file at /Users/<user>/.claude.json is corrupted: Unexpected end of JSON input` when tried to do `claude -p`
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?
Just suddenly started to throw:"Failed to authenticate. API Error: 401 Invalid authentication credentials"
And then when I wanted to export the conversation and hit claude -p in terminal, it gave Claude configuration file at /Users/<user>/.claude.json is corrupted: Unexpected end of JSON input
What Should Happen?
No corruption.
Error Messages/Logs
Steps to Reproduce
No specific steps. Just suddenly started to throw this every request:"Failed to authenticate. API Error: 401 Invalid authentication credentials"
And then when I wanted to export the conversation and hit claude -p in terminal, it gave Claude configuration file at /Users/<user>/.claude.json is corrupted: Unexpected end of JSON input
Did not do anything special. I think maybe concurrent agents were working on 2 separate repos, but I'm not sure. Regardless, it was a normal workflow.
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
Claude Code v2.1.168
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
VS Code integrated terminal
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗