Skip to content

Commit 4769942

Browse files
author
MarcoFalke
committed
Merge #19624: Warn on unknown rw_settings
fa48405 Warn on unknown rw_settings (MarcoFalke) Pull request description: Log a warning to debug log if unknown settings are encountered. This should probably only ever happen when the software is upgraded. Something similar is already done for the command line and config file. See: * test: Add test for unknown args #16234 (commit fa7dd88) ACKs for top commit: ryanofsky: Code review ACK fa48405. Looks good and I could see this being helpful for debugging. Thanks for taking suggestions Tree-SHA512: cec7d88adf84fa0a842f56b26245157736eb50df433db951e622ea07fd145b899822b24cdab1d8b36c066415ce4f0ef09b493fa8a8d691532822a59c573aafa7
2 parents d9d9a29 + fa48405 commit 4769942

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/util/system.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,14 @@ bool ArgsManager::ReadSettingsFile(std::vector<std::string>* errors)
427427
SaveErrors(read_errors, errors);
428428
return false;
429429
}
430+
for (const auto& setting : m_settings.rw_settings) {
431+
std::string section;
432+
std::string key = setting.first;
433+
(void)InterpretOption(section, key, /* value */ {}); // Split setting key into section and argname
434+
if (!GetArgFlags('-' + key)) {
435+
LogPrintf("Ignoring unknown rw_settings value %s\n", setting.first);
436+
}
437+
}
430438
return true;
431439
}
432440

test/functional/feature_settings.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,25 @@ def run_test(self):
3131

3232
# Assert settings are parsed and logged
3333
with settings.open("w") as fp:
34-
json.dump({"string": "string", "num": 5, "bool": True, "null": None, "list": [6,7]}, fp)
34+
json.dump({"string": "string", "num": 5, "bool": True, "null": None, "list": [6, 7]}, fp)
3535
with node.assert_debug_log(expected_msgs=[
36+
'Ignoring unknown rw_settings value bool',
37+
'Ignoring unknown rw_settings value list',
38+
'Ignoring unknown rw_settings value null',
39+
'Ignoring unknown rw_settings value num',
40+
'Ignoring unknown rw_settings value string',
3641
'Setting file arg: string = "string"',
3742
'Setting file arg: num = 5',
3843
'Setting file arg: bool = true',
3944
'Setting file arg: null = null',
40-
'Setting file arg: list = [6,7]']):
45+
'Setting file arg: list = [6,7]',
46+
]):
4147
self.start_node(0)
4248
self.stop_node(0)
4349

4450
# Assert settings are unchanged after shutdown
4551
with settings.open() as fp:
46-
assert_equal(json.load(fp), {"string": "string", "num": 5, "bool": True, "null": None, "list": [6,7]})
52+
assert_equal(json.load(fp), {"string": "string", "num": 5, "bool": True, "null": None, "list": [6, 7]})
4753

4854
# Test invalid json
4955
with settings.open("w") as fp:

0 commit comments

Comments
 (0)