Increases precision of error messages to help the user correct authentication issues.
Inspired by #34935.
Increases precision of error messages to help the user correct authentication issues.
Inspired by #34935.
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--021abf342d371248e50ceaed478a90ca-->
See the guideline for information on the review process.
| Type | Reviewers |
|---|---|
| ACK | davidgumberg, maflcko, achow101 |
| Concept ACK | janb84 |
If your review is incorrectly listed, please copy-paste <code><!--meta-tag:bot-skip--></code> into the comment that the bot should ignore.
<!--174a7506f384e20aa4161008e828411d-->
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.
<!--5faf32d7da4f0f540f40219e4f7537a3-->
AuthCookieResult::ERROR -> AuthCookieResult::ERR [The added Doxygen @retval AuthCookieResult::ERROR uses a non-existent enumerator name; the enum is ERR, so this would confuse readers about the intended return value.]
The LLM reminds me that ERROR (or any upper case name) may break when a windows (or other) header defines an ERROR macro, so I wonder if they can be changed to be CamelCase (Err, Ok, and Disabled).
Type will be used for reading the cookie in next commit.
Also corrects ERR/ERROR mismatch in docstring in request.h, and changes to CamelCase to avoid potential collision with Windows headers (https://github.com/bitcoin/bitcoin/pull/34965#issuecomment-4161331392).
Co-authored-by: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>Changed to CamelCase as suggested by #34965 (comment). Also spelled out Error.
Fixed interface_ipc_cli.py failure too.
Approve
Approve
952 | + break; 953 | + case AuthCookieResult::Disabled: 954 | + error += "Cookie file was disabled via -norpccookiefile and no rpcpassword was specified."; 955 | + break; 956 | + case AuthCookieResult::Ok: 957 | + error += "Cookie file credentials were invalid and no rpcpassword was specified.";
error += "Cookie file does not contain valid credentials and no rpcpassword was specified.";
NIT: found this error message a bit hard to understand. In the original error msg, you could read it as "the credentials of the cookie file where not valid" Or without seeing the other error states, I can imagine that users mistake this error message for something is wrong with the file, not with the credentials in the file.
Minor, but I see what you mean. Might be more succinct to rephrase it as:
error += "Credentials within cookie file were invalid and no rpcpassword was specified.";
Sorry I didn't get to this before the merge. Maybe it could be tacked on to a future PR.
959 | + } 960 | } else { 961 | - throw std::runtime_error("Authorization failed: Incorrect rpcuser or rpcpassword"); 962 | + error += "Incorrect rpcuser or rpcpassword were specified."; 963 | } 964 | + error += strprintf(" Configuration file: (%s)", fs::PathToString(gArgs.GetConfigFilePath()));
The config file path is now always included even when -rpcpassword was explicitly provided, is this intentional ?
./bitcoin-cli -regtest -rpcpassword=test -getinfo
error: Authorization failed: Incorrect rpcuser or rpcpassword were specified. Configuration file: (/Users/jan/Library/Application Support/Bitcoin/bitcoin.conf)
This seems reasonable, as it gives a hint to the user of where to look for the RPC authentication policy
I'm not aware of a way to detect the source of a setting (CLI/config file). Also, it could be that the -rpcpassword is correct, while the config file sets the wrong rpcuser. So I think the error message would still need to be somewhat ambiguous by nature.
concept ACK 257769a7ce8c8ca70e705569f29aac244ada45aa
I like the more informative errors which will provide the end user a bit more insight what went wrong and what to do to correct the issue.
utACK 257769a7ce8c8ca70e705569f29aac244ada45aa
review ACK 257769a7ce8c8ca70e705569f29aac244ada45aa 🦇
<details><summary>Show signature</summary>
Signature:
untrusted comment: signature from minisign secret key on empty file; verify via: minisign -Vm "${path_to_any_empty_file}" -P RWTRmVTMeKV5noAMqVlsMugDDCyyTSbA3Re5AkUrhvLVln0tSaFWglOw -x "${path_to_this_whole_four_line_signature_blob}"
RUTRmVTMeKV5npGrKx1nqXCw5zeVHdtdYURB/KlyA/LMFgpNCs+SkW9a8N95d+U4AP1RJMi+krxU1A3Yux4bpwZNLvVBKy0wLgM=
trusted comment: review ACK 257769a7ce8c8ca70e705569f29aac244ada45aa 🦇
QZkHoQvw0ab68HadxYfVHq0HiobaSq24W88DFigSjBhGs6tXhAJvPRTo4LdcaR9SzdVeW9whADndhfmhBCzXBg==
</details>
ACK 257769a7ce8c8ca70e705569f29aac244ada45aa
Thanks for the review @janb84!