mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
- The util/converter Prometheus response json parse was not checking for errors while parsing. It now does. In particular, if `[dataproxy]/response_limit` is set in Grafana's config, it will now recognize the limit error. - Fixes #73747 - Adds `jsonitere` package, which wraps json-iterator/go's Iterator's Methods with methods that return errors, so errcheck linting can be relied upon - Impact: - If something was sending malformed JSON to the prometheus or loki datasources, the previous code might have accepted that and partially processed the data - Before there may have been partial data with no error, where as no there may be errors but they will have no partial results, just the error.
61 lines
1.5 KiB
Go
61 lines
1.5 KiB
Go
// package jsonitere wraps json-iterator/go's Iterator methods with error returns
|
|
// so linting can catch unchecked errors.
|
|
// The underlying iterator's Error property is returned and not reset.
|
|
// See json-iterator/go for method documentation and additional methods that
|
|
// can be added to this library.
|
|
package jsonitere
|
|
|
|
import j "github.com/json-iterator/go"
|
|
|
|
type Iterator struct {
|
|
// named property instead of embedded so there is no
|
|
// confusion about which method or property is called
|
|
i *j.Iterator
|
|
}
|
|
|
|
func NewIterator(i *j.Iterator) *Iterator {
|
|
return &Iterator{i}
|
|
}
|
|
|
|
func (iter *Iterator) Read() (interface{}, error) {
|
|
return iter.i.Read(), iter.i.Error
|
|
}
|
|
|
|
func (iter *Iterator) ReadAny() (j.Any, error) {
|
|
return iter.i.ReadAny(), iter.i.Error
|
|
}
|
|
|
|
func (iter *Iterator) ReadArray() (bool, error) {
|
|
return iter.i.ReadArray(), iter.i.Error
|
|
}
|
|
|
|
func (iter *Iterator) ReadObject() (string, error) {
|
|
return iter.i.ReadObject(), iter.i.Error
|
|
}
|
|
|
|
func (iter *Iterator) ReadString() (string, error) {
|
|
return iter.i.ReadString(), iter.i.Error
|
|
}
|
|
|
|
func (iter *Iterator) WhatIsNext() (j.ValueType, error) {
|
|
return iter.i.WhatIsNext(), iter.i.Error
|
|
}
|
|
|
|
func (iter *Iterator) Skip() error {
|
|
iter.i.Skip()
|
|
return iter.i.Error
|
|
}
|
|
|
|
func (iter *Iterator) ReadVal(obj interface{}) error {
|
|
iter.i.ReadVal(obj)
|
|
return iter.i.Error
|
|
}
|
|
|
|
func (iter *Iterator) ReadFloat64() (float64, error) {
|
|
return iter.i.ReadFloat64(), iter.i.Error
|
|
}
|
|
|
|
func (iter *Iterator) ReadInt8() (int8, error) {
|
|
return iter.i.ReadInt8(), iter.i.Error
|
|
}
|