Add more errorsource attribution to InfluxDb datasource (#100969)

This PR adds errorsource attribution to the influxql and flux query paths
when the query model cannot be parsed, which is a user error.

It also catches cases where the datasource configuration does not
contain a scheme or host, and adds downstream attribution to those
errors.

Error handling on the influxql query path is updated to match 'all errors
are per query, and stashed on the response object' pattern.

Fixes https://github.com/grafana/oss-plugin-partnerships/issues/1250
This commit is contained in:
beejeebus
2025-02-20 11:53:28 -05:00
committed by GitHub
parent c8d4ff28a4
commit 9de769318c
3 changed files with 48 additions and 16 deletions
+8 -3
View File
@@ -1,6 +1,7 @@
package models
import (
"errors"
"fmt"
"strconv"
"time"
@@ -12,6 +13,10 @@ import (
"github.com/grafana/grafana/pkg/infra/log"
)
var (
ErrInvalidQuery = errors.New("invalid InfluxDB query")
)
type InfluxdbQueryParser struct{}
func QueryParse(query backend.DataQuery, logger log.Logger) (*Query, error) {
@@ -33,17 +38,17 @@ func QueryParse(query backend.DataQuery, logger log.Logger) (*Query, error) {
tags, err := parseTags(model)
if err != nil {
return nil, err
return nil, errors.Join(ErrInvalidQuery, err)
}
groupBys, err := parseGroupBy(model)
if err != nil {
return nil, err
return nil, errors.Join(ErrInvalidQuery, err)
}
selects, err := parseSelects(model)
if err != nil {
return nil, err
return nil, errors.Join(ErrInvalidQuery, err)
}
interval := query.Interval