Skip to content

Ignore unknown config file options; warn instead of error#13799

Merged
maflcko merged 2 commits intobitcoin:masterfrom
sipa:201807_warnunknown
Jul 31, 2018
Merged

Ignore unknown config file options; warn instead of error#13799
maflcko merged 2 commits intobitcoin:masterfrom
sipa:201807_warnunknown

Conversation

@sipa
Copy link
Member

@sipa sipa commented Jul 30, 2018

As reported by @satwo on IRC a few days ago, the current mechanism of treating unknown config file options as errors is problematic for options like -rpcclienttimeout which aren't defined for bitcoind.

A full solution would be to either make all binaries be aware of each other's options, or to permit config file options that only apply to specific binaries (bitcoind, bitcoin-qt, bitcoin-cli). Both of these seem too invasive to introduce for 0.17.

As a compromise, this PR makes it ignores those options, but still warn about it in the log file.

@sipa sipa force-pushed the 201807_warnunknown branch from b8a02f6 to a17ca7a Compare July 30, 2018 07:32
@sipa sipa force-pushed the 201807_warnunknown branch from a17ca7a to 5901ca4 Compare July 30, 2018 07:36
@ken2812221
Copy link
Contributor

Related #13441

@DrahtBot
Copy link
Contributor

Note to reviewers: This pull request conflicts with the following ones:

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use named arguments for literal primitive types. (/* ignore_invalid_keys */ true)

@laanwj
Copy link
Member

laanwj commented Jul 30, 2018

Tested ACK, we've discussed this on IRC and I think this is a good work-around for now.

Without:

$ src/bitcoind -rpcclienttimeout=1
Error parsing command line arguments: Invalid parameter -rpcclienttimeout
$ src/bitcoind -conf=/tmp/test.conf
Error reading configuration file: Invalid configuration value rpcclienttimeout

With:

$ src/bitcoind -rpcclienttimeout=1
Error parsing command line arguments: Invalid parameter -rpcclienttimeout
$ src/bitcoind -conf=/tmp/test.conf
[...]

(where /tmp/test.conf contains rpcclienttimeout=1)

It corrrectly rejects unknown direct arguments, but not those in the specified config file.

A full solution would be to either make all binaries be aware of each other's options

I strongly dislike this solution, it destroys all semblance of decoupling, modularity.

or to permit config file options that only apply to specific binaries (bitcoind, bitcoin-qt, bitcoin-cli).

This would be better, command-specific config sections would improve readability of configuration as well.

@maflcko maflcko added this to the 0.17.0 milestone Jul 30, 2018
@maflcko
Copy link
Member

maflcko commented Jul 30, 2018

utACK 5901ca411b420fe097e688425d624c7a8d9f1a30. Needs tests fixed/disabled.

@promag
Copy link
Contributor

promag commented Jul 30, 2018

utACK 5901ca4.

How about hardcode the exceptions for now and keep the error behavior?

@laanwj
Copy link
Member

laanwj commented Jul 30, 2018

How about hardcode the exceptions for now and keep the error behavior?

No, let's not do that. This solution is good. The implementation of errors for unknown arguments was primarily introduced for command-line arguments anyhow—see #1044—at least I never predicted the implications for configuration options, but it's a separate concern.

@ghost
Copy link

ghost commented Jul 30, 2018

Tested ACK 5901ca411b420fe097e688425d624c7a8d9f1a30.

Copy link
Member

@achow101 achow101 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test feature_includeconf.py has a test case for invalid options in the conf file. That will need to be removed or be updated.

src/util.cpp Outdated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work because logging is not setup at this point in startup. The warning does not appear in the debug.log.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I thought we cached early log messages and printed them afterwards. Any suggestions for how to deal with that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, #13088.

@achow101
Copy link
Member

achow101 commented Jul 30, 2018

Right now, to get around this problem, we already have a bunch of hidden arguments for the arguments from other binaries. I think it would be reasonable, at least for 0.17, to just extend that list to include the bitcoin-cli arguments. Then later we can add more invasive changes to actually fix the problem.

@sipa sipa force-pushed the 201807_warnunknown branch from 5901ca4 to 247d574 Compare July 31, 2018 01:01
@laanwj
Copy link
Member

laanwj commented Jul 31, 2018

re-utACK 247d574

@laanwj
Copy link
Member

laanwj commented Jul 31, 2018

I think it would be reasonable, at least for 0.17, to just extend that list to include the bitcoin-cli arguments.

No, I don't think that's reasonable. This solution is much better (I feel like I'm repeating myself...).

@maflcko maflcko merged commit 247d574 into bitcoin:master Jul 31, 2018
maflcko pushed a commit that referenced this pull request Jul 31, 2018
247d574 Ignore unknown config file options for now (Pieter Wuille)
04ce0d8 Report when unknown config file options are ignored (Pieter Wuille)

Pull request description:

  As reported by @satwo on IRC a few days ago, the current mechanism of treating unknown config file options as errors is problematic for options like `-rpcclienttimeout` which aren't defined for `bitcoind`.

  A full solution would be to either make all binaries be aware of each other's options, or to permit config file options that only apply to specific binaries (`bitcoind`, `bitcoin-qt`, `bitcoin-cli`). Both of these seem too invasive to introduce for 0.17.

  As a compromise, this PR makes it ignores those options, but still warn about it in the log file.

Tree-SHA512: dfddc771b91df3031a9c98d9f3292f8f4fcd1b97ebb7317b2f457e12d9f205dc63f42721302e7258dbb53f273d7cc041a65a0a9120972769555784e1f1cc9aef
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Mar 26, 2020
Summary:
```
As reported by @satwo on IRC a few days ago, the current mechanism of
treating unknown config file options as errors is problematic for
options like -rpcclienttimeout which aren't defined for bitcoind.

A full solution would be to either make all binaries be aware of each
other's options, or to permit config file options that only apply to
specific binaries (bitcoind, bitcoin-qt, bitcoin-cli). Both of these
seem too invasive to introduce for 0.17.

As a compromise, this PR makes it ignores those options, but still warn
about it in the log file.
```

Backport of core [[bitcoin/bitcoin#13799 | PR13799]].

Depends on D5553 (it is buggy otherwise).

Test Plan:
  ninja all check
  ./test/functional/test_runner.py feature_includeconf

Reviewers: #bitcoin_abc, jasonbcox

Reviewed By: #bitcoin_abc, jasonbcox

Differential Revision: https://reviews.bitcoinabc.org/D5554
UdjinM6 pushed a commit to UdjinM6/dash that referenced this pull request Jul 1, 2021
… of error

247d574 Ignore unknown config file options for now (Pieter Wuille)
04ce0d8 Report when unknown config file options are ignored (Pieter Wuille)

Pull request description:

  As reported by @satwo on IRC a few days ago, the current mechanism of treating unknown config file options as errors is problematic for options like `-rpcclienttimeout` which aren't defined for `bitcoind`.

  A full solution would be to either make all binaries be aware of each other's options, or to permit config file options that only apply to specific binaries (`bitcoind`, `bitcoin-qt`, `bitcoin-cli`). Both of these seem too invasive to introduce for 0.17.

  As a compromise, this PR makes it ignores those options, but still warn about it in the log file.

Tree-SHA512: dfddc771b91df3031a9c98d9f3292f8f4fcd1b97ebb7317b2f457e12d9f205dc63f42721302e7258dbb53f273d7cc041a65a0a9120972769555784e1f1cc9aef
UdjinM6 pushed a commit to UdjinM6/dash that referenced this pull request Jul 2, 2021
… of error

247d574 Ignore unknown config file options for now (Pieter Wuille)
04ce0d8 Report when unknown config file options are ignored (Pieter Wuille)

Pull request description:

  As reported by @satwo on IRC a few days ago, the current mechanism of treating unknown config file options as errors is problematic for options like `-rpcclienttimeout` which aren't defined for `bitcoind`.

  A full solution would be to either make all binaries be aware of each other's options, or to permit config file options that only apply to specific binaries (`bitcoind`, `bitcoin-qt`, `bitcoin-cli`). Both of these seem too invasive to introduce for 0.17.

  As a compromise, this PR makes it ignores those options, but still warn about it in the log file.

Tree-SHA512: dfddc771b91df3031a9c98d9f3292f8f4fcd1b97ebb7317b2f457e12d9f205dc63f42721302e7258dbb53f273d7cc041a65a0a9120972769555784e1f1cc9aef
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants