Chore: Change response status for dashboard import with invalid input (#81521)
* Return BadRequest when dashboard import failed due to invalid input
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
"github.com/grafana/grafana/pkg/api/apierrors"
|
||||
@@ -10,6 +11,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
||||
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
|
||||
"github.com/grafana/grafana/pkg/services/dashboardimport"
|
||||
"github.com/grafana/grafana/pkg/services/dashboardimport/utils"
|
||||
"github.com/grafana/grafana/pkg/services/dashboards"
|
||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||
"github.com/grafana/grafana/pkg/services/quota"
|
||||
@@ -77,6 +79,9 @@ func (api *ImportDashboardAPI) ImportDashboard(c *contextmodel.ReqContext) respo
|
||||
req.User = c.SignedInUser
|
||||
resp, err := api.dashboardImportService.ImportDashboard(c.Req.Context(), &req)
|
||||
if err != nil {
|
||||
if errors.Is(err, utils.ErrDashboardInputMissing) {
|
||||
return response.Error(http.StatusBadRequest, err.Error(), err)
|
||||
}
|
||||
return apierrors.ToDashboardErrorResponse(c.Req.Context(), api.pluginStore, err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user