mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
fix: Error message for ledger_entry rpc (#5344)
Changes the error to `malformedAddress` for `permissioned_domain` in the `ledger_entry` rpc, when the account is not a string. This change makes it more clear to a user what is wrong with their request.
This commit is contained in:
@@ -3189,7 +3189,18 @@ class LedgerRPC_test : public beast::unit_test::suite
|
||||
params[jss::permissioned_domain][jss::account] = 1;
|
||||
params[jss::permissioned_domain][jss::seq] = seq;
|
||||
auto const jrr = env.rpc("json", "ledger_entry", to_string(params));
|
||||
checkErrorValue(jrr[jss::result], "malformedRequest", "");
|
||||
checkErrorValue(jrr[jss::result], "malformedAddress", "");
|
||||
}
|
||||
|
||||
{
|
||||
// Fail, account is an object
|
||||
Json::Value params;
|
||||
params[jss::ledger_index] = jss::validated;
|
||||
params[jss::permissioned_domain][jss::account] =
|
||||
Json::Value{Json::ValueType::objectValue};
|
||||
params[jss::permissioned_domain][jss::seq] = seq;
|
||||
auto const jrr = env.rpc("json", "ledger_entry", to_string(params));
|
||||
checkErrorValue(jrr[jss::result], "malformedAddress", "");
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
@@ -822,12 +822,18 @@ parsePermissionedDomains(Json::Value const& pd, Json::Value& jvResult)
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
if (!pd.isMember(jss::account) || !pd[jss::account].isString())
|
||||
if (!pd.isMember(jss::account))
|
||||
{
|
||||
jvResult[jss::error] = "malformedRequest";
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
if (!pd[jss::account].isString())
|
||||
{
|
||||
jvResult[jss::error] = "malformedAddress";
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
if (!pd.isMember(jss::seq) ||
|
||||
(pd[jss::seq].isInt() && pd[jss::seq].asInt() < 0) ||
|
||||
(!pd[jss::seq].isInt() && !pd[jss::seq].isUInt()))
|
||||
|
||||
Reference in New Issue
Block a user