mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
[MM-27836] Fix possible panic when patching config (#15262)
* Fix possible panic when updating/patching config * Remove un-needed check
This commit is contained in:
@@ -180,7 +180,7 @@ func patchConfig(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
appCfg := c.App.Config()
|
||||
if *appCfg.ServiceSettings.SiteURL != "" && *cfg.ServiceSettings.SiteURL == "" {
|
||||
if *appCfg.ServiceSettings.SiteURL != "" && (cfg.ServiceSettings.SiteURL == nil || *cfg.ServiceSettings.SiteURL == "") {
|
||||
c.Err = model.NewAppError("patchConfig", "api.config.update_config.clear_siteurl.app_error", nil, "", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -550,6 +550,12 @@ func TestPatchConfig(t *testing.T) {
|
||||
cfg, resp = th.SystemAdminClient.GetConfig()
|
||||
CheckNoError(t, resp)
|
||||
require.Equal(t, nonEmptyURL, *cfg.ServiceSettings.SiteURL)
|
||||
|
||||
// Check that sending an empty config returns an error.
|
||||
_, resp = th.SystemAdminClient.PatchConfig(&model.Config{})
|
||||
require.NotNil(t, resp.Error)
|
||||
CheckBadRequestStatus(t, resp)
|
||||
assert.Equal(t, "api.config.update_config.clear_siteurl.app_error", resp.Error.Id)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user