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

Mitigate possible mis-configuration problems #205

Open
Conal-Tuohy opened this issue Sep 7, 2023 · 1 comment
Open

Mitigate possible mis-configuration problems #205

Conal-Tuohy opened this issue Sep 7, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request needs-more-thought

Comments

@Conal-Tuohy
Copy link
Collaborator

I've experienced a few instances of configuration issues where the JSON configuration file has been modified and the code has been modified to use the new config, but I haven't got the memo and have encountered runtime problems that have sometimes been mysterious. e.g. #194

The problem is that the configuration file contains localised values including secrets, so it isn't under version control, which means changes to the file's schema need to be communicated "out of band", which is a hassle and error-prone (easy to forget).

I've had some thoughts about how we could mitigate the risk of issues like this re-occurring in future.

One improvement could be to strengthen the code which directly accesses sub-properties of the configuration object loaded from the JSON file, so that it's wrapped in a function that logs any errors e.g. replace

var crucial = configuration.foo.bar.someCrucialConfigurationSetting`

with

var crucial = getConfigurationSetting('foo.bar.someCrucialConfigurationSetting')`

Another possibility, which would be even easier to implement, would be to have some kind of on-boot validation of the configuration file that would log a warning about any discrepancy between the config file that's in effect, and the dummy 'example' version of the file which is under version control. If the two files had any differences in their structure (i.e. the sets of property names), that would be easy to detect with a simple recursive descent of the two objects in parallel, and that would catch most changes. Would that work? Or does the configuration actually have optional components, that might legitimately vary between the example configuration file and the local configuration?

I had a look at JSON schema support in Node and there are packages that certainly seem easy to use, once you have a schema for your JSON document, but maintaining a JSON schema for the configuration file seems like a lot of work when we're really only interested in the simplest kind of validation, which I think a simple comparison with an "example" configuration would provide.

@marcolarosa
Copy link
Contributor

This file: https://github.com/CoEDL/nyingarn-workspace/blob/master/configuration/example-configuration.json is always up to date with whatever changes I make to the configuration when I make them. That should be the first place you look if something is screwy. Or email me. There's only two of us so we should be able to make this work without adding a layer of stuff into the API. Especially since this isn't happening constantly.

I'll aim to do better at keeping you up to date with changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs-more-thought
Projects
None yet
Development

No branches or pull requests

2 participants