Opserver icon indicating copy to clipboard operation
Opserver copied to clipboard

System.NullReferenceException When Oncall Schedule Doesn't Have User

Open jzhang-sre opened this issue 3 years ago • 1 comments

@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

jzhang-sre avatar Feb 23 '22 15:02 jzhang-sre

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 :)

NickCraver avatar Mar 08 '22 13:03 NickCraver