Skip to content

Guard against empty files array in FileEditorCodeMirror#8423

Merged
iHiD merged 1 commit intomainfrom
fix/8419
Feb 8, 2026
Merged

Guard against empty files array in FileEditorCodeMirror#8423
iHiD merged 1 commit intomainfrom
fix/8419

Conversation

@iHiD
Copy link
Copy Markdown
Member

@iHiD iHiD commented Feb 8, 2026

Closes #8419

Summary

  • Add early return guard in FileEditorCodeMirror when files prop is empty or undefined
  • Prevents TypeError: Cannot read properties of undefined (reading '0') when accessing files[0].filename
  • This can occur when localStorage returns an empty array for saved editor files
  • Follows existing defensive pattern used in FilePanel and IterationFiles components

Test plan

  • All 65 Editor-related JS tests pass (19 test suites)
  • Pre-commit hooks pass (prettier)

🤖 Generated with Claude Code

Return null early when the files prop is empty or undefined, preventing
a TypeError when accessing files[0].filename. This can occur when
localStorage returns an empty array for saved files.

Closes #8419

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@iHiD iHiD requested a review from dem4ron as a code owner February 8, 2026 20:50
@iHiD iHiD merged commit 0fcb2be into main Feb 8, 2026
41 checks passed
@iHiD iHiD deleted the fix/8419 branch February 8, 2026 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeError: Cannot read properties of undefined (reading '0')

1 participant