Closed fcovatti closed 4 years ago
29.10.19 22:11:35 (-0300) panic: runtime error: index out of range
29.10.19 22:11:35 (-0300) goroutine 1 [running]:
29.10.19 22:11:35 (-0300) encoding/binary.bigEndian.Uint64(...)
29.10.19 22:11:35 (-0300) /usr/local/go/src/encoding/binary/binary.go:124
29.10.19 22:11:35 (-0300) main.IDM.AddPoints(0x1074aa0, 0x8, 0x19dd4b4, 0x5f03ab, 0x1068640, 0x1b, 0x1c, 0x0, 0x0, 0x0, ...)
29.10.19 22:11:35 (-0300) /go/pkg/mod/github.com/bemasher/rtlamr-collect/main.go:78 +0x908
29.10.19 22:11:35 (-0300) main.main()
29.10.19 22:11:35 (-0300) /go/pkg/mod/github.com/bemasher/rtlamr-collect/main.go:426 +0x5fc
The commit message for the fix is misleading. binary.BigEndian.Uint64 will fail on index out of bounds because the byte slice isn't guaranteed to be 8 bytes long when idm.Outage flags is empty.
The new code will always succeed even if idm.Outage contains no data.
Thanks for the Update. Tested and it worked after the change!
NetIDM meters dont report the PowerOutageFlags on the json causing AddPoints function to raise a runtime error at the following line:
https://github.com/bemasher/rtlamr-collect/blob/master/main.go#L78
I am not sure how to best fix this as I am not experienced on go, but could you take a look at it? I did comment out the outage and hardcoded it to 1 in the "For each differential interval." loop and it stopped raising the runtime error.
Thanks!