-
Notifications
You must be signed in to change notification settings - Fork 661
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
Graceful fallback when config is missing a property? #2938
Comments
At the moment we have a python script
@kevinkreiser @purew What do you think about it? But right now I think that this task will only put spokes in our wheels in the future. We will not control the freshness of the data in config.json. |
Currently, we don't validate the json before using it and thats why we sometime get errors deep within the code when a property is accessed for the first time. 1 easy thing to do would be to put in schema validation before using the config. Another option is to have a config abstraction built on top of what the user-supplied config json which is then used internally. The internal config representation can make decisions on what default values to use if an attribute is missing (it can simply store the schema-validated json document internally and provide a similar API as the JSON doc). Eg: if you try to get an attribute thats optional, and its not supplied in the user config, the internal abstraction can return a default value. |
I like this idea of parsing the json once and then ending up with something like
I'm not sure if it could be worse than the current situation. Default values can change today as well with people running older configs. The benefit of implementing this ticket is that should a default value change, it'd be a seamless upgrade with a new valhalla binary as you'd get the updated value if you haven't specified an explicit value in your existing config file. So from that perspective it'd be better, right? An example: I'm only really interested in running large matrix requests, so my config.json really only specifies bigger limits on matrix and nothing else (apart from the basedata). Any changes to default values in newer valhalla binaries would apply to me as soon as I upgrade because I haven't been forced to specify them in the config file already. |
Yeah I swear I wrote an issue about having config loaded/validated once at start up. I hadn't thought about default values though I understand why that would be desirable. I would like to point out that there are a few types of values in the config:
for the second type, @CuriOusQuOkka has a good point. it is possible that a person comes to rely on the default but then the default changes and whatever they were doing is now impacted. i dont see a way around this other than people becoming more responsible for configuring their software (which is ok with me, you have to have a clue to some degree about what you are doing). I find it very difficult to suggest defaults for the third type. the only thing we can do there is maybe not have defaults for those and make those such that the user must supply them? or we could put defaults that basically dont work without user intervention (which is what we do now). the big question would be can you use valhalla without a config at all or must you at least supply a tile_dir/tile_extract? implementation-wise what are we suggesting here concretely? is it something like the following?
if so i might suggest we do a minor revision release after this to signal a more significant change of functionality |
Currently the scope looks bigger than we expected and the task is not prioritised. Will pause it for now. |
It would be useful if a missing property in the config file fell back gracefully to the default value, rather than killing the process with a hard error.
Is there any appetite for such a change? We could potentially specify default values in a json file that the C++ code reads at compile time and the python script
valhalla_build_config
parses at runtime?An example would be forgetting to add
loki.service_defaults.street_side_tolerance
to theconfig.json
. Then the router crashes likeThe text was updated successfully, but these errors were encountered: