fix: Have endpoint_stops/2 not crash when given an empty set of routes
#2913
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Scope
No ticket. I noticed that SF2.0 was crashing in the presence of 👇 systemwide alert.
That alert has the attributes that it is a
:service_change, whichstatus_row_heading/1tries to endow with endpoint stops, and it has no routes associated with it.The correct behavior here is to return
[]- no endpoint-stops.The current behavior is to crash and present the (admittedly well-designed) 500 page.
Implementation
endpoint_stops/2checks the route ID's provided, and if there are no non-nil route ID's given, it short-circuits and returns[].Screenshots
How to test
Visit any bus page (how about this one?) in SF2.0 and rejoice.
Notes
This is only affecting SF2.0 right now, because SF2.0 is the only place where
<.status_row_heading />is rendered for bus alerts. The alerts on the existing bus alerts page, for instance, use a different component that doesn't render endpoint stops.