Bug #10282

[Go programs] Error out when unrecognized keys appear in config files

Added by Tom Clegg over 2 years ago. Updated 21 days ago.

Status:
New
Priority:
Normal
Assigned To:
-
Category:
-
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Story points:
-

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 an error message and exit non-zero when this happens, to avoid running services with configuration different than intended.

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 filesNew2016-11-22

Blocked by Arvados - Feature #10141: [Packaging] Include sample config file (/etc/arvados/foo/foo.example.yml) with each configurable packageNew2016-09-28

History

#1 Updated by Tom Clegg over 2 years ago

  • Description updated (diff)

#2 Updated by Tom Morris about 2 years ago

  • Assigned To set to Tom Morris
  • Target version set to Arvados Future Sprints

#3 Updated by Tom Clegg about 2 years ago

  • Subject changed from Log a warning when unrecognized keys appear in config files to Error out when unrecognized keys appear in config files
  • Description updated (diff)

#4 Updated by Tom Clegg about 2 years ago

  • Description updated (diff)
  • Subject changed from Error out when unrecognized keys appear in config files to [Go programs] Error out when unrecognized keys appear in config files

#5 Updated by Tom Morris 21 days ago

  • Assigned To deleted (Tom Morris)
  • Target version changed from Arvados Future Sprints to To Be Groomed

Also available in: Atom PDF