odota / web

React web interface for the OpenDota platform
https://www.opendota.com
MIT License
1.08k stars 390 forks source link

Page not loading due to unhandled null value in match metadata #3127

Closed nicholasluimy closed 7 months ago

nicholasluimy commented 7 months ago

Current Behavior React frontend error trying to cast null toString

Expected behavior/code Code should handle null values

Console Output Uncaught TypeError: Cannot read properties of null (reading 'toString')

Possible Solution

Compiled code source, line that's erroring out: let r = E_(e.tower_status_radiant.toString(2), 16).slice(5); Metadata json loaded via network call has "tower_status_radiant": null,

Actual code: https://github.com/odota/web/blob/master/src/components/Match/BuildingMap/BuildingMap.jsx#L283

Above, we see a patch handler where it handles when tower_status_radiant is undefined, but not when it's null https://github.com/odota/web/blob/master/src/components/Match/BuildingMap/BuildingMap.jsx#L276-L278

Possible solution: return empty section when information is unavailable?

Although this also hints at the API possibly returning bad data (tower status should never be null?)

Match ID: https://www.opendota.com/matches/7468445438

nicholasluimy commented 7 months ago

Seems like it's a dupe of #3126