Add errorsource to InfluxDB datasource plugin fixes #1072 (#99900)

This PR adds `backend.ErrorSourceDownstream` values to all `backend.DataResponse`
values where it's certain that the error wasn't the result of the
InfluxDB datasource plugin.
This commit is contained in:
beejeebus
2025-02-04 09:33:32 -05:00
committed by GitHub
parent 1f0ff19471
commit cfae9d20d2
11 changed files with 81 additions and 9 deletions
@@ -30,7 +30,10 @@ func parse(buf io.Reader, statusCode int, query *models.Query) *backend.DataResp
if errorStr == "" {
errorStr = response.Message
}
return &backend.DataResponse{Error: fmt.Errorf("InfluxDB returned error: %s", errorStr)}
return &backend.DataResponse{
Error: fmt.Errorf("InfluxDB returned error: %s", errorStr),
ErrorSource: backend.ErrorSourceFromHTTPStatus(statusCode),
}
}
if jsonErr != nil {
@@ -38,12 +41,18 @@ func parse(buf io.Reader, statusCode int, query *models.Query) *backend.DataResp
}
if response.Error != "" {
return &backend.DataResponse{Error: errors.New(response.Error)}
return &backend.DataResponse{
Error: errors.New(response.Error),
ErrorSource: backend.ErrorSourceDownstream,
}
}
result := response.Results[0]
if result.Error != "" {
return &backend.DataResponse{Error: errors.New(result.Error)}
return &backend.DataResponse{
Error: errors.New(result.Error),
ErrorSource: backend.ErrorSourceDownstream,
}
}
if query.ResultFormat == "table" {