-
Notifications
You must be signed in to change notification settings - Fork 38.8k
util: Improve documentation and negation of args #31212
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
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/31212. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsReviewers, 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. |
rkrux
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK 9e130811a3f68aea77ddeecf667aa8389a2940e8
Thanks for catching issues here, gave me an opportunity to read the app init code a bit more!
Successful make and functional tests. Left couple suggestions in the first 2 commits. Disallowing noconf and nodatadir conceptually makes sense to me. I tested with these 2 args and the output I received seems okay to me.
➜ bitcoin git:(2024/11/invalid_args) ✗ bitcoinclireg -noconf
Error parsing command line arguments: Negating of -conf is meaningless and therefore forbidden
➜ bitcoin git:(2024/11/invalid_args) ✗ bitcoinclireg -nodatadir
Error parsing command line arguments: Negating of -datadir is meaningless and therefore forbidden
Though I don't completely understand why this comment "ok to not have a config file" (and subsequent flow) is allowed because when I ran the CLI without any arg I received the version info, help options, & too few args message.
https://github.com/hodlinator/bitcoin/blob/2024/11/invalid_args/src/common/config.cpp#L138
My guess it is applicable when the daemon is run without a conf because this portion lies in |
My interpretation is that we shouldn't trigger an error on not finding a configuration file in the |
9e13081 to
6fbea75
Compare
But it's not. Seems like |
As mentioned in the commit message for 2d65e6ae0756b87e82dbafd032308e8687ec7941:
It's sheer luck when it comes to how Here is The part of
It would be good to add detection of "directory as config path" and trigger an error, regardless of which path is given. But I'm still inclined to disallow |
|
Concept ACK |
|
Added commit which now guards against passing directory paths as |
|
Code review d9cfb2a314caa1cdcae8e47a03dad557ad96e069. This generally looks good except commit 2d65e6ae0756b87e82dbafd032308e8687ec7941 disallowing --- a/src/common/config.cpp
+++ b/src/common/config.cpp
@@ -131,7 +131,7 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
std::ifstream stream{conf_path};
// not ok to have a config file specified that cannot be opened
- if (IsArgSet("-conf") && !stream.good()) {
+ if ((IsArgSet("-conf") && !IsArgNegated("-conf")) && !stream.good()) {
error = strprintf("specified config file \"%s\" could not be opened.", fs::PathToString(conf_path));
return false;
}
@@ -213,7 +213,7 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
fs::path AbsPathForConfigVal(const ArgsManager& args, const fs::path& path, bool net_specific)
{
- if (path.is_absolute()) {
+ if (path.is_absolute() || path.empty()) {
return path;
}
return fsbridge::AbsPathJoin(net_specific ? args.GetDataDirNet() : args.GetDataDirBase(), path);I don't think it's right to infer from |
20e950b to
77c8a53
Compare
|
@ryanofsky thanks for the review! Updated to cover negation for all users of |
ryanofsky
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code review 77c8a538b7164f8b65576600eb4668ac160f6b14. Thanks for the updates! This all looks great, my only substantial comments are about the RPC commit which I think is more complicated than it needs to be and may have a bug where it may allow an empty auth string to be accepted if -norpccookiefile is specified, or if there is an initialization failure.
It may be nice to add python functional tests to exercise some of the new behaviors. It would be nontrivial work to add test coverage for all of these behaviors, but it doesn't have to be all-or-nothing. Just having some new end-to-end tests of argument parsing edge cases would be a nice improvement to our existing test coverage.
3c223b0 to
4680acc
Compare
4680acc to
41fc05c
Compare
hodlinator
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for continued review and reminding me to raise the bar for the PR @ryanofsky.
Added tests which helped uncover that bitcoin-cli might as well also support -norpccookiefile too, and part of src/common/init.cpp which was not handling -noconf correctly.
1465250 to
c30e89f
Compare
|
Further idea:
|
😅 Good one! I'll create a "Good first issue" for it. |
41d934c chore: Typo Overriden -> Overridden (Hodlinator) c9fb38a refactor test: Cleaner combine_logs.py logic (Hodlinator) Pull request description: - Fixes typo caught by spelling linter (https://github.com/bitcoin/bitcoin/runs/33979284676). - Minor but nice refactoring of *combine_logs.py* change that was suggested late: #31212 (comment) ACKs for top commit: l0rinc: ACK 41d934c maflcko: lgtm ACK 41d934c theStack: ACK 41d934c BrandonOdiwuor: Code Review ACK 41d934c tdb3: ACK 41d934c Tree-SHA512: cf8ecc070d0b01df9c4e57a75820e17d4535591e85bf9d271c7b8f60875f7e04b9978c56e9b88c10e89e69ff755c35b23ed291949c32c875a91c3317105a3c79
-coloras only applying to-getinfo, to be less confusing for bitcoin-cli users.-noversion.-nodatadiras we cannot run without one. It was previously interpreted as a mix of unset and as a relative path of "0".-norpccookiefile-nopid-noconf(instead of working by accident). Also detect when directories are specified instead of files.Prompted by investigation in #16545 (review).