Project

General

Profile

Actions

Bug #10282

closed

[Go programs]Warn or error when unrecognized keys appear in config files

Added by Tom Clegg over 7 years ago. Updated almost 5 years ago.

Status:
Closed
Priority:
Normal
Assigned To:
-
Category:
-
Target version:
-
Story points:
1.0

Description

Currently, if a configuration key is misspelled or misplaced in a configuration file, it is silently ignored.

Programs that read configuration files should print a warning message when this happens, to avoid running services with configuration different than intended. Support an optional flag which converts the warning to an error and causes the program to exit.

There is a Go feature in the works that would be helpful. Even with that, we'd still need our YAML library to expose DisallowUnknownFields() -- either that, or convert YAML → map[string]interface{} → JSON and then load the resulting JSON to the real struct using DisallowUnknownFields().

If we don't want to wait, we could detect invalid keys by comparing site config to example config (but do not read the example config from /etc at runtime -- rather, build the example config into the Go binary). Load both configs into a map[string]interface{}, then do a recursive "A's keys are a subset of B's keys" test.


Related issues

Related to Arvados - Feature #10594: [API] [Workbench] Error out when unrecognized keys appear in config filesNewActions
Related to Arvados - Idea #15003: [config] Go package & tool for preprocessing cluster config fileResolvedTom Clegg04/26/2019Actions
Blocked by Arvados - Feature #10141: [Packaging] Include sample config file (/etc/arvados/foo/foo.example.yml) with each configurable packageClosed09/28/2016Actions
Actions

Also available in: Atom PDF