bookingcom / carbonapi

High-performance Graphite frontend in Go
Other
81 stars 23 forks source link

Checking absent array size during marshaling #491

Closed deniszh closed 1 year ago

deniszh commented 1 year ago

What issue is this change attempting to solve?

Recovered panic index out of range [1] with length 1 when we have fewer elements in absent results than normal results:

github.com/bookingcom/carbonapi/pkg/expr/types.MarshalJSON({0xc19c012c48, 0x3, 0x3?}) /usr/local/git_tree/gopath/src/github.com/bookingcom/carbonapi/pkg/expr/types/types.go:169 +0x4bd

How does this change solve the problem? Why is this the best approach?

Let's check array size beforehand