[MM-17616] v4.2: Update config.json file validation to prevent loosing config settings on upgrade #1015
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
After analyzing the
config.json
file from a client experiencing the disappearing server problem after updating from 4.2.1 to 4.2.2, it seems that in theirconfig.json
files, thetrayIconTheme
option was set to a blank string instead of thelight
ordark
options. The Validator was written to expect eitherlight
ordark
and so the validation was failing. Digging deeper into the code, it looks like it might actually be possible to have a blank value for that option (it's really only a Linux option), so the Validator has been updated to allow for that.While the team URL wasn't actually the problem in this case it is still a possibility, so the validator has also been updated to convert any
\
characters to/
characters and then further checks each updated URL individually to ensure they are each in fact a validly constructed URL. If any are not valid URLs they are individually filtered out, allowing the other URLs to remain instead of wiping out all configured servers for the sake of one.In addition, the URL input in the
Add Server
modal now properly validates a URL provided by a user before saving to theconfig.json
file.These changes will need to be applied to the master branch as well as part of the pending security updates.
Issue link
https://mattermost.atlassian.net/browse/MM-17616
Test Cases
Test URL's:
https://community.mattermost.com\
(include the incorrect backslash)Test
trayIconTheme
option:config.json
file to set the value fortrayIconTheme
to a blank string ("trayIconTheme": ""
)