Merge pull request #997 from SigNoz/dashboard-bug-fix

(bugfix): remove validation on post data id
This commit is contained in:
Ankit Nayan 2022-04-18 14:37:46 +05:30 committed by GitHub
commit 844ca57686
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 16 deletions

View File

@ -182,9 +182,7 @@ func GetDashboard(uuid string) (*Dashboard, *model.ApiError) {
return &dashboard, nil
}
func UpdateDashboard(data *map[string]interface{}) (*Dashboard, *model.ApiError) {
uuid := (*data)["uuid"].(string)
func UpdateDashboard(uuid string, data *map[string]interface{}) (*Dashboard, *model.ApiError) {
map_data, err := json.Marshal(data)
if err != nil {
@ -224,12 +222,7 @@ func (d *Dashboard) UpdateSlug() {
func IsPostDataSane(data *map[string]interface{}) error {
val, ok := (*data)["uuid"]
if !ok || val == nil {
return fmt.Errorf("uuid not found in post data")
}
val, ok = (*data)["title"]
val, ok := (*data)["title"]
if !ok || val == nil {
return fmt.Errorf("title not found in post data")
}

View File

@ -13,10 +13,10 @@ import (
"github.com/prometheus/prometheus/promql"
"go.signoz.io/query-service/app/dashboards"
"go.signoz.io/query-service/dao/interfaces"
am "go.signoz.io/query-service/integrations/alertManager"
"go.signoz.io/query-service/model"
"go.signoz.io/query-service/telemetry"
"go.signoz.io/query-service/version"
am "go.signoz.io/query-service/integrations/alertManager"
"go.uber.org/zap"
)
@ -337,12 +337,7 @@ func (aH *APIHandler) updateDashboard(w http.ResponseWriter, r *http.Request) {
return
}
if postData["uuid"] != uuid {
aH.respondError(w, &model.ApiError{Typ: model.ErrorBadData, Err: fmt.Errorf("uuid in request param and uuid in request body do not match")}, "Error reading request body")
return
}
dashboard, apiError := dashboards.UpdateDashboard(&postData)
dashboard, apiError := dashboards.UpdateDashboard(uuid, &postData)
if apiError != nil {
aH.respondError(w, apiError, nil)