Errors: Make errors the same in dev as prod (#77366)

When running in dev mode, error messages would contain an additional "error" property alongside "message". Since this causes confusion, that has been removed and now error messages are the same both modes (using "message").
This commit is contained in:
Kyle Brandt
2023-10-30 14:06:26 -04:00
committed by GitHub
parent 40df27a4da
commit e4d1fdc3d0
12 changed files with 16 additions and 49 deletions

View File

@@ -69,19 +69,16 @@ func TestDataProxy(t *testing.T) {
// Tests request to datasource proxy service
func TestDatasourceProxy_proxyDatasourceRequest(t *testing.T) {
tcs := []struct {
name string
dsURL string
expectedErrorMsg string
name string
dsURL string
}{
{
name: "Empty datasource URL will return a 400 HTTP status code",
dsURL: "",
expectedErrorMsg: "validation of data source URL \"\" failed: empty URL string",
name: "Empty datasource URL will return a 400 HTTP status code",
dsURL: "",
},
{
name: "Invalid datasource URL will return a 400 HTTP status code",
dsURL: "://host/path",
expectedErrorMsg: "validation of data source URL \"://host/path\" failed: parse \"://host/path\": missing protocol scheme",
name: "Invalid datasource URL will return a 400 HTTP status code",
dsURL: "://host/path",
},
}
for _, tc := range tcs {
@@ -124,7 +121,6 @@ func TestDatasourceProxy_proxyDatasourceRequest(t *testing.T) {
require.Equal(t, http.StatusBadRequest, resp.StatusCode)
require.Equal(t, fmt.Sprintf("Invalid data source URL: %q", tc.dsURL), jsonBody["message"])
require.Equal(t, tc.expectedErrorMsg, jsonBody["error"])
})
}
}