fix: add null checks for tactic/technique toLowerCase calls#201
Conversation
Backend sometimes returns null for tactic/technique fields, causing 'Cannot read properties of null' errors. Added optional chaining. Fixes logtide-dev#200
|
Hi @impsislegobatman, thanks for taking a stab at this! A couple of notes before we can merge:
We've already pushed a fix in |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
The route parameter is required, so the optional chaining is unreachable. Keeping only the defensive changes in shared/utils/mitre.ts as suggested in review.
|
Thanks for following up on the feedback so quickly! The trim to keep just the defensive changes in shared/utils/mitre.ts is exactly what we discussed clean second commit too. Quick note on context: the actual crash from #200 (Cannot read properties of null from the MITRE heatmap) was fixed in #203 by filtering out null tactic/technique cells in MitreHeatmap.svelte, which just landed on main. So #200 is already resolved at the source. Merging this PR as additional hardening your ?. additions still help any future caller of these helpers that might receive a null/undefined value, so it's good defensive code to have. |
Fixes #200
Added optional chaining (
?.) before.toLowerCase()calls on tactic and technique fields that the backend sometimes returns as null.