mirror of
https://github.com/grafana/grafana.git
synced 2024-11-24 09:50:29 -06:00
datasources: querier: request parsing failures are not http 500 (#94488)
* datasources: querier: request parsing failures are not http500 * fix test --------- Co-authored-by: Adam Simpson <adam@adamsimpson.net>
This commit is contained in:
parent
c6c93a02aa
commit
0a7b731242
@ -122,15 +122,22 @@ func (r *queryREST) Connect(connectCtx context.Context, name string, _ runtime.O
|
||||
// Parses the request and splits it into multiple sub queries (if necessary)
|
||||
req, err := b.parser.parseRequest(ctx, raw)
|
||||
if err != nil {
|
||||
reason := metav1.StatusReasonInvalid
|
||||
message := err.Error()
|
||||
|
||||
if errors.Is(err, datasources.ErrDataSourceNotFound) {
|
||||
reason = metav1.StatusReasonNotFound
|
||||
// TODO, can we wrap the error somehow?
|
||||
err = &errorsK8s.StatusError{ErrStatus: metav1.Status{
|
||||
Status: metav1.StatusFailure,
|
||||
Code: http.StatusBadRequest, // the URL is found, but includes bad requests
|
||||
Reason: metav1.StatusReasonNotFound,
|
||||
Message: "datasource not found",
|
||||
}}
|
||||
message = "datasource not found"
|
||||
}
|
||||
|
||||
err = &errorsK8s.StatusError{ErrStatus: metav1.Status{
|
||||
Status: metav1.StatusFailure,
|
||||
Code: http.StatusBadRequest,
|
||||
Reason: reason,
|
||||
Message: message,
|
||||
}}
|
||||
|
||||
responder.Error(err)
|
||||
return
|
||||
}
|
||||
|
@ -143,9 +143,8 @@ func TestIntegrationSimpleQuery(t *testing.T) {
|
||||
"apiVersion": "v1",
|
||||
"metadata": {},
|
||||
"status": "Failure",
|
||||
"message": "did not execute expression [Y] due to a failure to of the dependent expression or query [X]",
|
||||
"reason": "BadRequest",
|
||||
"details": { "uid": "sse.dependencyError" },
|
||||
"message": "[sse.dependencyError] did not execute expression [Y] due to a failure to of the dependent expression or query [X]",
|
||||
"reason": "Invalid",
|
||||
"code": 400
|
||||
}`, string(body))
|
||||
// require.JSONEq(t, `{
|
||||
|
Loading…
Reference in New Issue
Block a user