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

when setting config keys, validate against struct before writing to disk #742

Merged
merged 4 commits into from
Feb 4, 2015

Conversation

btc
Copy link
Contributor

@btc btc commented Feb 4, 2015

RFCR @jbenet @whyrusleeping

This addresses one part of #740. Now, the config is validated before being written to disk. Mismatched types will be rejected instead of being written to disk and breaking the config.

@btc btc added the status/in-progress In progress label Feb 4, 2015
@btc btc force-pushed the fix/repo-config-validation branch from 9f5cfac to 3d59622 Compare February 4, 2015 00:54
When setting config keys, the program doesn't know whether the
key-to-be-modified exists on the Config struct. (Perhaps, with
reflection, it is possible to find the field). To allow callers to write
non-existent keys, the program would...

Before:
1) converts the in-memory *Config to a map
2) sets the key on the map, and
3) writes this map to disk.
4) Then, it converts this map back into an in-memory struct.

This commit swaps 3 and 4 so the map can be validated against the struct
before being written to disk. This prevents the bug identified in #740.
@jbenet
Copy link
Member

jbenet commented Feb 4, 2015

LGTM. we should probably have tests for both setting/getting the config, and making sure logs dont grow unboundedly (maybe set a low limit, throw N events to go over that limit, and check?). If you want to merge this now, I can write these later.

btc pushed a commit that referenced this pull request Feb 4, 2015
when setting config keys, validate against struct before writing to disk
@btc btc merged commit 75ffca6 into master Feb 4, 2015
@btc btc removed the status/in-progress In progress label Feb 4, 2015
@btc btc deleted the fix/repo-config-validation branch February 4, 2015 02:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants