[BUG] Cannot read properties of null (reading 'split') crash in Edit tool result renderer when originalFile is null

Resolved 💬 2 comments Opened Mar 27, 2026 by jaceyang97 Closed Mar 29, 2026

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?

The Edit tool's result rendering component (renderToolResultMessage for the Edit tool) crashes with a TypeError when the originalFile field is null. The function unconditionally calls .split('\n') on originalFile without a null guard:
// Deminified from cli.js:3332
function renderEditResult({ filePath, structuredPatch, originalFile }, _ctx, { style, verbose }) {
let isPlan = filePath.startsWith(planDir());
return createElement(DiffViewer, {
filePath,
structuredPatch,
firstLine: originalFile.split('\n')[0] ?? null, // <-- crashes here when originalFile is null
fileContent: originalFile,
style,
verbose,
previewHint: isPlan ? "/plan to preview" : void 0,
});
}

When originalFile is null, null.split(...) throws TypeError: Cannot read properties of null (reading 'split'), which kills the session.

What Should Happen?

The renderer should handle null gracefully, e.g.:
firstLine: originalFile?.split('\n')[0] ?? null,
Or guard at the top of the function and render a fallback (similar to how the same component already handles !Y || Y.length === 0 for empty hunks a few lines above).

Error Messages/Logs

ERROR  Cannot read properties of null (reading 'split')

file:///~/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:3332:1650

- Object.uzK (cli.js:3332:1650)      ← Edit tool result renderer
- wxq (cli.js:2783:6264)              ← renderToolResultMessage dispatcher
- DO (cli.js:755:20996)
- PO (cli.js:755:39538)
- AJ6 (cli.js:755:50231)
- PR (cli.js:755:86911)
- wd8 (cli.js:755:85875)
- JS6 (cli.js:755:85696)
- B48 (cli.js:755:82447)
- K8 (cli.js:755:6485)

Steps to Reproduce

The exact trigger is unclear

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.85

Platform

AWS Bedrock

Operating System

Ubuntu/Debian Linux

Terminal/Shell

VS Code integrated terminal

Additional Information

_No response_

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗