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:
Sergey Kuznetsov
2025-03-17 13:14:49 +00:00
committed by GitHub
parent c0299dba88
commit d9b7a2688f
2 changed files with 19 additions and 2 deletions

View File

@@ -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", "");
}
{

View File

@@ -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()))