Bug: undefined is not an object (evaluating '_.startsWith') after bulk file deletion

Resolved 💬 3 comments Opened Mar 22, 2026 by wxmpro Closed Mar 25, 2026

Bug Report: undefined is not an object (evaluating '_.startsWith')

Description

Claude Code crashes with undefined is not an object (evaluating '_.startsWith') after performing bulk file deletion operations.

Error Details

Error Message:

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

/$bunfs/root/src/entrypoints/cli.js:3142:1937

Stack Trace:

  • kF7 (cli.js:3142:1937)
  • EW7 (cli.js:2593:44450)
  • SA, BH, G8, Ce_, P3_, Py_, jy_, OT (cli.js:675:...)

Environment

  • Claude Code Version: 2.1.81
  • OS: macOS (Darwin 25.3.0, arm64, MacBook Pro M1)
  • Node.js: v25.2.1
  • Shell: zsh

Steps to Reproduce

  1. Delete a large number of files (100+ files in my case)
  2. Files were in 01_openmind_note/ directory and subdirectories
  3. After deletion, Claude Code returned this error

Current Repository State

  • Working directory: /Users/xinmin/openmind
  • Git status: Many files in deleted (D) state
  • Modified files: .DS_Store, .claude/settings.local.json

Root Cause Analysis

The error occurs in the diff/patch rendering code (kF7 function at cli.js:3142). When processing bulk deleted files, a variable expected to be a string is undefined, but the code attempts to call .startsWith() on it without null checking.

Suggested Fix

Add null/undefined checks in the diff rendering logic before calling string methods. Specifically around cli.js:3142, ensure variables are properly initialized when handling deleted files.

Impact

This bug prevents Claude Code from functioning after bulk file deletion operations, requiring a restart to recover.

View original on GitHub ↗

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