mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
ds-querier: return error if failed to get ds client (#97698)
* ds-querier: return error if failed to get ds client * add log line * no empty ref * fix test
This commit is contained in:
parent
27c979b0bf
commit
57d94ed01f
@ -125,7 +125,7 @@ func (r *queryREST) Connect(connectCtx context.Context, name string, _ runtime.O
|
||||
var refError ErrorWithRefID
|
||||
statusCode := http.StatusBadRequest
|
||||
message := err
|
||||
refID := ""
|
||||
refID := "A"
|
||||
|
||||
if errors.Is(err, datasources.ErrDataSourceNotFound) {
|
||||
statusCode = http.StatusNotFound
|
||||
@ -187,6 +187,11 @@ func (b *QueryAPIBuilder) execute(ctx context.Context, req parsedRequestInfo) (q
|
||||
qdr, err = b.executeConcurrentQueries(ctx, req.Requests)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
b.log.Debug("error in query phase, skipping expressions", "error", err)
|
||||
return qdr, err //return early here to prevent expressions from being executed if we got an error during the query phase
|
||||
}
|
||||
|
||||
if len(req.Expressions) > 0 {
|
||||
b.log.Debug("executing expressions")
|
||||
qdr, err = b.handleExpressions(ctx, req, qdr)
|
||||
@ -232,7 +237,9 @@ func (b *QueryAPIBuilder) handleQuerySingleDatasource(ctx context.Context, req d
|
||||
req.Headers,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
b.log.Debug("error getting single datasource client", "error", err, "reqUid", req.UID)
|
||||
qdr := buildErrorResponse(err, req)
|
||||
return qdr, err
|
||||
}
|
||||
|
||||
code, rsp, err := client.QueryData(ctx, *req.Request)
|
||||
|
@ -140,7 +140,7 @@ func TestIntegrationSimpleQuery(t *testing.T) {
|
||||
require.Error(t, err, "expecting a 400")
|
||||
require.JSONEq(t, `{
|
||||
"results": {
|
||||
"": {
|
||||
"A": {
|
||||
"error": "[sse.dependencyError] did not execute expression [Y] due to a failure to of the dependent expression or query [X]",
|
||||
"status": 400,
|
||||
"errorSource": ""
|
||||
|
Loading…
Reference in New Issue
Block a user