#22786: fix: guard against undefined file.path in system-prompt-report
agents
size: XS
Cluster:
Bootstrap and Plugin Fixes
## Summary
- Adds a null/undefined guard for `file.path` in `buildInjectedWorkspaceFiles()` to prevent `TypeError: Cannot read properties of undefined (reading 'replace')` when workspace bootstrap files have missing paths
Fixes #22693
## Local Validation
- [x] Code review: guard prevents crash when `file.path` is `undefined`
- [x] Existing tests pass (the guard simply skips entries with no path)
## Scope
XS — 3-line guard addition in one file
## AI Assistance
Used Claude Code for issue identification and fix implementation.
## Author
@miloudbelarebia
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Adds a defensive guard to prevent crashes when `file.path` is undefined in workspace bootstrap files. The fix prevents `TypeError: Cannot read properties of undefined (reading 'replace')` by skipping files with missing paths when building the injected basename map.
<h3>Confidence Score: 5/5</h3>
- Safe to merge - defensive guard prevents crash without changing behavior
- The fix is minimal, defensive, and correctly prevents the crash by skipping problematic entries. The guard only affects the basename map building, and files with undefined paths will still be processed by the main map lookup on line 58. The logic is sound and follows defensive programming practices.
- No files require special attention
<sub>Last reviewed commit: f92821b</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#18647: fix(agents): guard against undefined paths in injectedFiles
by kleinpanic · 2026-02-16
83.7%
#22723: fix: guard against undefined path in buildInjectedWorkspaceFiles — ...
by Fratua · 2026-02-21
79.1%
#22859: fix: guard against undefined fileOps properties in compaction safeg...
by miloudbelarebia · 2026-02-21
77.7%
#20851: fix: harden resolveUserPath and compact against undefined workspaceDir
by davidrudduck · 2026-02-19
77.1%
#21954: Prevent bootstrap hook truncation crash in prompt report
by graysurf · 2026-02-20
75.3%
#12174: fix(agents): add path containment check in apply_patch for non-sand...
by coygeek · 2026-02-08
74.2%
#11529: fix(wizard): strip shell-style backslash escapes from workspace paths
by mcaxtr · 2026-02-07
73.5%
#22711: fix: post-compaction audit skips non-existent required files
by taw0002 · 2026-02-21
72.9%
#12939: fix(memory): strip null bytes from workspace paths causing ENOTDIR
by omair445 · 2026-02-09
72.8%
#13577: fix(onboard): validate workspace directory before setup steps
by mcaxtr · 2026-02-10
72.7%