e-mission / e-mission-docs

Repository for docs and issues. If you need help, please file an issue here. Public conversations are better for open source projects than private email.
https://e-mission.readthedocs.io/en/latest
BSD 3-Clause "New" or "Revised" License
15 stars 34 forks source link

Json config file nightmare #832

Open sblaisot opened 1 year ago

sblaisot commented 1 year ago

e-mission server uses json configuration files. However, Json is not a friendly config file format as it is a data-only file format that doesn't allow for comments.

Currently, comments are inserted in config files as __comment object keys but that lead to duplicate object keys as in https://github.com/e-mission/e-mission-server/blob/master/conf/net/api/webserver.conf.sample#L10-L18

RFC 8259 (The JavaScript Object Notation (JSON) Data Interchange Format), section 4 states that :

The names within an object SHOULD be unique.

Duplicate object keys lead to undefined behaviour across systems (currently python json.load() is permissive and only keep last value so it basically appears to work by ignoring all but last comment)

Switching to a more config-friendly format with rich data structures like Yaml or Toml in the future appears to be a nice move.

shankari commented 1 year ago

@sblaisot I agree that the lack of comments in JSON is annoying. I originally picked json because it was included in both python and javascript without the need for any third party libraries. However, we now have a standard mechanism (environment.yml) to load third party python libraries in python, so that reason is no longer relevant.

However, this is also not a very high priority for the OpenPATH team - which is focused on the admin dashboard, UI improvements, and server scalability.

However, we would welcome contributions to make this change, even if they are incremental - one config file at a time 😄

shankari commented 1 year ago

I do still prefer raw JSON for the dynamic config (e.g. https://github.com/e-mission/nrel-openpath-deploy-configs) because then I can limit the number of external javascript libraries that we need to load for the really simple webapps such as https://github.com/e-mission/nrel-openpath-join-page/