opserver / Opserver

Stack Exchange's Monitoring System
https://opserver.github.io/Opserver/
MIT License
4.51k stars 828 forks source link

System.NullReferenceException When Oncall Schedule Doesn't Have User #405

Open jzhang-sre opened 2 years ago

jzhang-sre commented 2 years ago

@NickCraver we have an on call schedule that only has people during the weekend, it's blank during the weekday so we get this object reference error:

System.NullReferenceException: Object reference not set to an instance of an object.
   at AspNetCore.Views_PagerDuty_PagerDuty_OnCallRow.ExecuteAsync() in /_/src/OpServer.Web/Views/PagerDuty/PagerDuty.OnCallRow.cshtml:line 3

My C# is bad but I think an if statement wrapping the following line checking if the fields in the object are not null would fix this.

https://github.com/opserver/Opserver/blob/ed57f51d26a061e75359c1a3245786b795ae93b7/Opserver/Views/PagerDuty/PagerDuty.cshtml#L104

NickCraver commented 2 years ago

hmm, this would seem to imply we get a schedule that has a null entry which seems off upstream - can anyone at Stack verify? (I don't have data access). FWIW, it'd be super helpful if the team could sanity check the #401 branch - I'm not sure what Stack's using at the moment but Opserver's ready to merge down to main on a LTS release if that's good with y'all.

For example, I can't tell which branch/code this is on :)