fix: Cannot read properties of undefined (reading 'format')#2
fix: Cannot read properties of undefined (reading 'format')#2
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Automated fix by Exterminator
Error: Cannot read properties of undefined (reading 'format')
Source:
Location: Line 0, Col 0
Fix summary
The
formatNodefunction used TypeScript's non-null assertion (node.metadata!.format) on a field that is genuinelyundefinedat runtime for all incomplete-task nodes and for the synthetic root node created byaggregateNodes, causing a TypeError when the report tree was walked.Replaced
node.metadata!.formatwithnode.metadata?.format ?? "n/a"in theformatNodefunction. The optional chaining (?.) safely short-circuits toundefinedwhenmetadatais absent, and the nullish coalescing (?? "n/a") substitutes a readable placeholder instead of crashing. This fixes the root cause without suppressing the error or altering any other logic.Changed files
src/pages/Dashboard.tsxSummary by CodeRabbit