go-graphite / carbonapi

Implementation of graphite API (graphite-web) in golang
Other
308 stars 140 forks source link

holtWinters: fix panic on small season lengths #715

Closed npazosmendez closed 2 years ago

npazosmendez commented 2 years ago

We found this panic in HoltWintersAnalysis

runtime error: index out of range [0] with length 0\", stack='\"goroutine .. [running]

after some debugging I found where it was coming from: a big step in a series was causing a very small seasonLength, which was invalid for the HoltWintersAnalysis function. I also noted GraphiteWeb has this bug too, so I filed an issue there https://github.com/graphite-project/graphite-web/issues/2780 (I left more details about the problem there).

The fix I propose here is to force seasonLength to be at least 2, but we can see what GraphiteWeb's maintainers propose and match their decision later.