Assign errorsource to InfluxDB Flux http errors (#102823)

InfluxDB Flux queries can return a http.Error type that we can use to
assign errorsource to.

This PR checks for that type of error, and uses our errorsource
machinery to assign an errorsource.

This is part of https://github.com/grafana/data-sources/issues/377
This commit is contained in:
beejeebus authored and GitHub committed 2025-03-26 08:00:06 -04:00
1 parent cc8b40585b
commit 709723927f
1 file changed
+6
+6
View File
@@ -9,6 +9,7 @@ import (
"github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/grafana/grafana-plugin-sdk-go/data"
"github.com/influxdata/influxdb-client-go/v2/api"
"github.com/influxdata/influxdb-client-go/v2/api/http"
"github.com/grafana/grafana/pkg/infra/log"
)
@@ -26,6 +27,11 @@ func executeQuery(ctx context.Context, logger log.Logger, query queryModel, runn
tables, err := runner.runQuery(ctx, flux)
if err != nil {
var influxHttpError *http.Error
if errors.As(err, &influxHttpError) {
dr.ErrorSource = backend.ErrorSourceFromHTTPStatus(influxHttpError.StatusCode)
dr.Status = backend.Status(influxHttpError.StatusCode)
}
logger.Warn("Flux query failed", "err", err, "query", flux)
dr.Error = err
} else {