[BUG] claude --resume crashes with undefined is not an object when session contains diff metadata with missing filePath
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?
aclaude --resume crashes with undefined is not an object (evaluating 'H.startsWith') at cljs:822848:/ when the session JSONL contains structuredPatch/diffPatch metadata with an undefined filePath property.
The crash occurs in function Q0K({filePath:H, structuredPatch:$, originalFile:q}) which calls H.startsWith(J0()) without null-checking H. When a session's diff metadata has a missing or undefined filePath, the TUI renderer crashes and the entire session becomes unresumable.
What Should Happen?
aclaude --resume should gracefully handle session JSONL files that contain structuredPatch/diffPatch metadata with a missing or undefined filePath. The fix would be a simple optional chaining check (H?.startsWith instead of H.startsWith) in the Q0K function, so that sessions with malformed diff metadata can still be resumed without crashing the TUI renderer.
Error Messages/Logs
Steps to Reproduce
a1. Have a long Claude Code session with multiple file edits (Edit tool calls)
- Session completes normally
- 3. Run
claude --resumeto resume the session - 4. Claude crashes with:
undefined is not an object (evaluating 'H.startsWith')
The session JSONL file contains structuredPatch/diffPatch entries where the filePath property is undefined. This causes the TUI renderer to crash when trying to call .startsWith() on an undefined value.
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.86 (Claude Code)
Platform
AWS Bedrock
Operating System
Windows
Terminal/Shell
PowerShell
Additional Information
_No response_
5 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
Hit this same crash on v2.1.86, Windows 11, GCP Vertex AI backend.
Specific trigger: Using the Write tool to create temporary files (for clipboard operations), then deleting them with
rmin the same session. About 11 Write+Delete cycles in a 560-line session. Everyclaude --resumecrashes immediately.What I tried to fix the JSONL (none of it worked):
originalFile: nullto""in alltoolUseResultentriestoolUseResultfields entirely (155 entries)tool_useblocks inmessage.contentto text blocksThe crash persists because the diff rendering promise chain (
j3f->W3f->Q0K) reconstructs diffs from the tool_use input at render time, not just from the storedtoolUseResult. When the file doesn't exist, the promise resolves with undefinedfilePath, andQ0KcallsH.startsWith()on it.The session is irrecoverable. Had to move the JSONL aside and start fresh.
Workaround I'm using now: avoid the Write+Delete pattern entirely. For clipboard operations, I use PowerShell directly (
Set-Clipboard) instead of writing to a temp file.My Claude says your issue shares a similar pattern with #39565 (Claude commits/pushes without approval despite explicit CLAUDE.md instructions) and #40117 (Claude bypasses git pre-commit hooks using multiple tactics despite explicit deny rules). The common thread: Claude receives a clear "don't do this" and does it anyway. In your case it's even worse — the denial came directly from the user in conversation, not just from CLAUDE.md or hooks.
Should be fixed in v2.1.99
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.