Crash: undefined is not an object in Edit tool renderer (file_path null check)

Status Closed — duplicate
Maintainer reply None cached
Activity 3 comments · opened Mar 31, 2026 · closed Apr 4, 2026

Bug Description

Claude Code crashes with undefined is not an object (evaluating 'H.startsWith') when the Edit tool's result renderer receives an undefined file_path.

Error

ERROR  undefined is not an object (evaluating 'H.startsWith')

/$bunfs/root/src/entrypoints/cli.js:1772:487

Stack Trace

- DR7 (/$bunfs/root/src/entrypoints/cli.js:1772:487)
- Ce7 (/$bunfs/root/src/entrypoints/cli.js:2929:18047)
- _w (/$bunfs/root/src/entrypoints/cli.js:453:20997)
- $O (/$bunfs/root/src/entrypoints/cli.js:453:39538)
- Ks (/$bunfs/root/src/entrypoints/cli.js:453:50229)
- sEH (/$bunfs/root/src/entrypoints/cli.js:453:86903)
- M0 (/$bunfs/root/src/entrypoints/cli.js:453:85865)
- aEH (/$bunfs/root/src/entrypoints/cli.js:453:85687)
- WDH (/$bunfs/root/src/entrypoints/cli.js:453:82433)
- FH (/$bunfs/root/src/entrypoints/cli.js:453:6488)

Root Cause

The YR7 function (deobfuscated from the minified source) renders Edit tool results and calls H.startsWith(PT()) where H is file_path. When file_path is undefined, this throws a TypeError.

From the minified source:

function YR7({file_path:H},{verbose:_}){
  if(!H) return null;           // ← guard exists here
  if(H.startsWith(PT())) return "";
  return i3.createElement(wW,{filePath:H},_?H:i$(H))
}

However, the calling function DR7 does NOT guard before passing to a different code path:

function DR7({filePath:H,structuredPatch:_,originalFile:q},$,{style:K,verbose:O}){
  let T=H.startsWith(PT());  // ← crashes here, no null check on H (filePath)
  ...
}

DR7 is the structured patch renderer and receives filePath which can be undefined when the Edit tool result doesn't include a file path.

Reproduction

This occurred during a session where the model was actively editing files as part of a multi-step skill integration task (adding PagerDuty/Grafana maintenance window logic into existing skills). The crash happened mid-conversation, losing all in-progress work context.

Expected Behavior

The renderer should guard against undefined filePath before calling .startsWith(), similar to how YR7 already does with its if(!H) return null check.

Environment

  • OS: macOS (Darwin 25.3.0)
  • Shell: zsh
  • Date: 2026-03-31

View original on GitHub ↗

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