[BUG] claude --resume crashes with undefined is not an object when session contains diff metadata with missing filePath

Status Fixed / completed
Reported on v2.1.86
Maintainer reply ✓ Yes — mhegazy
Activity 5 comments · opened Mar 28, 2026 · closed Apr 10, 2026
💡 Likely answer: A maintainer (mhegazy, contributor) responded on this thread — see the highlighted reply below.

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)

  1. Session completes normally
  2. 3. Run claude --resume to resume the session
  3. 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_

View original on GitHub ↗

5 Comments

github-actions[bot] · 6 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/39542
  2. https://github.com/anthropics/claude-code/issues/38633
  3. https://github.com/anthropics/claude-code/issues/37454

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

mkhellafi-worldline · 6 months ago

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 rm in the same session. About 11 Write+Delete cycles in a 560-line session. Every claude --resume crashes immediately.

What I tried to fix the JSONL (none of it worked):

  1. Set originalFile: null to "" in all toolUseResult entries
  2. Stripped all toolUseResult fields entirely (155 entries)
  3. Converted the Write tool_use blocks in message.content to text blocks
  4. Converted them to Read tool_use blocks

The 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 stored toolUseResult. When the file doesn't exist, the promise resolves with undefined filePath, and Q0K calls H.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.

marlvinvu · 6 months ago

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.

mhegazy contributor · 6 months ago

Should be fixed in v2.1.99

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.