DataSource: change status code to 404 if datasource and plugin is not found (#36426)

Fixes #36418
This commit is contained in:
Tharun Rajendran 2021-07-05 18:16:34 +05:30 committed by GitHub
parent 4932b9dfa4
commit f62bc59688
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -46,6 +46,10 @@ func (p *DatasourceProxyService) ProxyDatasourceRequestWithID(c *models.ReqConte
c.JsonApiErr(http.StatusForbidden, "Access denied to datasource", err)
return
}
if errors.Is(err, models.ErrDataSourceNotFound) {
c.JsonApiErr(http.StatusNotFound, "Unable to find datasource", err)
return
}
c.JsonApiErr(http.StatusInternalServerError, "Unable to load datasource meta data", err)
return
}
@ -59,7 +63,7 @@ func (p *DatasourceProxyService) ProxyDatasourceRequestWithID(c *models.ReqConte
// find plugin
plugin := p.PluginManager.GetDataSource(ds.Type)
if plugin == nil {
c.JsonApiErr(http.StatusInternalServerError, "Unable to find datasource plugin", err)
c.JsonApiErr(http.StatusNotFound, "Unable to find datasource plugin", err)
return
}