Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ConfigFile much more reliable. #113

Open
2 of 4 tasks
s0lst1ce opened this issue May 7, 2020 · 2 comments
Open
2 of 4 tasks

Make ConfigFile much more reliable. #113

s0lst1ce opened this issue May 7, 2020 · 2 comments
Assignees
Labels
bug Something isn't working quality all issues which only affect the way code is written and that won't affect functionnality

Comments

@s0lst1ce
Copy link
Collaborator

s0lst1ce commented May 7, 2020

Describe the bug
As of now nearly no checks are done on the files being read as config. This is a big issue because sometimes we can end up with empty JSON which cannot be read by the std json library.
Moreover the website expects to always receive JSON files with all possible fields, although some may have placeholder values.

Steps to reproduce
It is unclear how exactly such issues occur. Most often another exception is risen while the file is open. Or parsing to save fails and the file can't be read anymore. Or Updates cause issues with old files.
The exact conditions to be met for the issue to arise is vague.

Expected behavior
Make sure all JSON config files, whatever they configure, always have all fields they should. This should be checked at startup and enforced throughout runtime.

Todo

  • make use of default configuration files for in-place replacements in case of an issue
  • have default files in each different config folder to be used as default
  • have a JSON checker
  • check all files on startup
@s0lst1ce s0lst1ce added the bug Something isn't working label May 7, 2020
@s0lst1ce s0lst1ce self-assigned this May 7, 2020
@s0lst1ce s0lst1ce linked a pull request May 7, 2020 that will close this issue
@s0lst1ce s0lst1ce added the quality all issues which only affect the way code is written and that won't affect functionnality label May 8, 2020
@s0lst1ce
Copy link
Collaborator Author

The JSON checker would be quite heavy. I think that finding out where and why issues sometimes occur with the json module is more efficient.
Still it is impossible to guarantee no errors will be left. For this I have added failsafes that should make sure the JSON files on disk are always sound, at the cost of eventual data losses (although I don't know if they can really be caused). By this I mean that an operation handling a JSON might fail and the ConfigFile handler will discard the changes instead of invalidating the JSON.

s0lst1ce added a commit that referenced this issue May 16, 2020
@s0lst1ce
Copy link
Collaborator Author

I believe jsonschema would be perfect to assert the validity of our JSONs.

@s0lst1ce s0lst1ce reopened this May 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working quality all issues which only affect the way code is written and that won't affect functionnality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant