Repository: zcash/zcash (language: rust)

Issue:
`zcash_cli` crashes when arguments fail to parse
The following crashes: 
```
nuttycom@sword:~/work/zcash/release (conventional-fee-sentinel)λ ./src/zcash-cli z_getoperationstatus ["opid-ab077a65-5289-49fb-844b-2f46a114e2dc"]
zcash-cli: /home/nuttycom/work/zcash/release/depends/x86_64-pc-linux-gnu/share/../include/tl/expected.hpp:1937: E &tl::expected<UniValue, UniValue>::error() & [T = UniValue, E = UniValue]: Assertion `!has_value()' failed.
Aborted (core dumped)
```
whereas this succeeds: 
```
./src/zcash-cli z_getoperationstatus '["opid-ab077a65-5289-49fb-844b-2f46a114e2dc"]'
```
Note that the latter correctly quotes the array parameter.


Discussion / hints:
Likely related to the https://github.com/zcash/zcash/pull/6448 changes

Fix patch:
diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp
index 5844469e73e..2657e199c66 100644
--- a/src/bitcoin-cli.cpp
+++ b/src/bitcoin-cli.cpp
@@ -212,12 +212,12 @@ UniValue ConvertValues(const std::string &strMethod, const std::vector<std::stri
                             auto helpMsg = CallRPC("help", ConvertValues("help", {strMethod}));
                             return "\n\n"
                                 + (helpMsg.has_value()
-                                   ? strprintf(
+                                   ? "Usage: " + helpMsg.value().get_str()
+                                   : strprintf(
                                            "An error occurred while attempting to retrieve the "
                                            "help text for %s: %s",
                                            strMethod,
-                                           helpMsg.error().get_str())
-                                   : helpMsg->get_str());
+                                           helpMsg.error().get_str()));
                         }
                     }));
         })
diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp
index 4c38b8cb59b..3683d3dab80 100644
--- a/src/rpc/client.cpp
+++ b/src/rpc/client.cpp
@@ -189,7 +189,7 @@ std::string FormatConversionFailure(const std::string& strMethod, const Conversi
                         err.providedParams);
             },
             [](const UnparseableParam& err) {
-                return std::string("Error parsing JSON:") + err.unparsedParam;
+                return std::string("Error parsing JSON: ") + err.unparsedParam;
             }
         });
 }


Test patch:
diff --git a/src/test/rpc_tests.cpp b/src/test/rpc_tests.cpp
index 209a78af013..9befebe9675 100644
--- a/src/test/rpc_tests.cpp
+++ b/src/test/rpc_tests.cpp
@@ -404,7 +404,7 @@ BOOST_AUTO_TEST_CASE(rpc_insightexplorer)
     CheckRPCThrows("getblockhashes 1477641360 1477641360 {\"noOrphans\":true,\"logicalTimes\":1}",
         "JSON value is not a boolean as expected");
     CheckRPCThrows("getblockhashes 1477641360 1477641360 {\"noOrphans\":True,\"logicalTimes\":false}",
-        "Error parsing JSON:{\"noOrphans\":True,\"logicalTimes\":false}");
+        "Error parsing JSON: {\"noOrphans\":True,\"logicalTimes\":false}");
 
     // revert
     fExperimentalInsightExplorer = false;
diff --git a/src/wallet/test/rpc_wallet_tests.cpp b/src/wallet/test/rpc_wallet_tests.cpp
index cd4b4454a76..39475c56604 100644
--- a/src/wallet/test/rpc_wallet_tests.cpp
+++ b/src/wallet/test/rpc_wallet_tests.cpp
@@ -1570,7 +1570,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_mergetoaddress_parameters)
 
     // bad from address
     CheckRPCThrows("z_mergetoaddress ** " + taddr2,
-        "Error parsing JSON:**");
+        "Error parsing JSON: **");
 
     // bad from address
     CheckRPCThrows("z_mergetoaddress [\"**\"] " + taddr2,
@@ -1578,11 +1578,11 @@ BOOST_AUTO_TEST_CASE(rpc_z_mergetoaddress_parameters)
 
     // bad from address
     CheckRPCThrows("z_mergetoaddress " + taddr1 + " " + taddr2,
-        "Error parsing JSON:" + taddr1);
+        "Error parsing JSON: " + taddr1);
 
     // bad from address
     CheckRPCThrows("z_mergetoaddress [" + taddr1 + "] " + taddr2,
-        "Error parsing JSON:[" + taddr1 + "]");
+        "Error parsing JSON: [" + taddr1 + "]");
 
     // bad to address
     CheckRPCThrows("z_mergetoaddress [\"" + taddr1 + "\"] INVALID" + taddr2,