From 7833e595aabb0acdec24d6e4a53f77c3fd110fdf Mon Sep 17 00:00:00 2001 From: Michael Kochell <6913320+mickmister@users.noreply.github.com> Date: Fri, 3 Jun 2022 10:14:56 -0400 Subject: [PATCH] [MM-44604] Ensure we return after setting error in api4/config.go (#20294) --- api4/config.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/api4/config.go b/api4/config.go index f219d76221..94043bb1a8 100644 --- a/api4/config.go +++ b/api4/config.go @@ -62,6 +62,7 @@ func getConfig(c *Context, w http.ResponseWriter, r *http.Request) { }) if err != nil { c.Err = model.NewAppError("getConfig", "api.config.get_config.restricted_merge.app_error", nil, err.Error(), http.StatusInternalServerError) + return } auditRec.Success() @@ -137,6 +138,7 @@ func updateConfig(c *Context, w http.ResponseWriter, r *http.Request) { }) if err1 != nil { c.Err = model.NewAppError("updateConfig", "api.config.update_config.restricted_merge.app_error", nil, err1.Error(), http.StatusInternalServerError) + return } // Do not allow plugin uploads to be toggled through the API @@ -198,7 +200,8 @@ func updateConfig(c *Context, w http.ResponseWriter, r *http.Request) { }, }) if mergeErr != nil { - c.Err = model.NewAppError("updateConfig", "api.config.update_config.restricted_merge.app_error", nil, err.Error(), http.StatusInternalServerError) + c.Err = model.NewAppError("updateConfig", "api.config.update_config.restricted_merge.app_error", nil, mergeErr.Error(), http.StatusInternalServerError) + return } auditRec.Success() @@ -354,7 +357,8 @@ func patchConfig(c *Context, w http.ResponseWriter, r *http.Request) { }, }) if mergeErr != nil { - c.Err = model.NewAppError("patchConfig", "api.config.patch_config.restricted_merge.app_error", nil, err.Error(), http.StatusInternalServerError) + c.Err = model.NewAppError("patchConfig", "api.config.patch_config.restricted_merge.app_error", nil, mergeErr.Error(), http.StatusInternalServerError) + return } w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")