go-graphite / carbonapi

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

Fix error handling in helper.ForEachSeriesDo #726

Closed carrieedwards closed 2 years ago

carrieedwards commented 2 years ago

This PR addresses an issue in helper.ForEachSeriesDo and helper.ForEachSeriesDo1 in which an error returned by GetSeriesArg was ignored, and an ErrMissingTimeSeries error was returned in all cases. This can mask the real cause of the error. GetSeriesArg will return an ErrMissingTimeSeries or the appropriate error from evaluating the expression, so ForEachSeriesDo should return the error that GetSeriesArg returns, and not hard-code the error type as ErrMissingTimeSeries. An example of where the true error could be masked is if the argument is a nested function that contains a parameter that is an invalid type. In this case, an ErrBadType should be returned.