-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
fix: better error handling in account RPCs #5065
Conversation
8f94f3c
to
1739568
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #5065 +/- ##
=======================================
Coverage 71.3% 71.4%
=======================================
Files 796 796
Lines 67031 67055 +24
Branches 10885 10869 -16
=======================================
+ Hits 47808 47847 +39
+ Misses 19223 19208 -15
|
This change could also be done by editing |
account_info
RPCfe1ebed
to
2dfdfc8
Compare
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.
Looks fine to me. Leaving a few nits and questions 👍
if (!(params.isMember(jss::account) || params.isMember(jss::ident))) | ||
return RPC::missing_field_error(jss::account); | ||
|
||
std::string strIdent; |
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.
nit: can be avoided via immediately invoked lambda
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.
Given that the lambda would be handling errors, it'll be more readable etc. if it's left as-is, and probably wouldn't have any performance improvements to switch.
@@ -53,9 +54,17 @@ doAccountInfo(RPC::JsonContext& context) | |||
|
|||
std::string strIdent; |
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.
nit: Same improvement possible
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.
Because this branch is based on master
, RippledCode.cmake
needs to be updated to reflect the renaming of AccountLinesRPC_test.cpp
to AccountLines_test.cpp
.
Closing as this patch is included in #5078 |
High Level Overview of Change
This PR adds a check for whether the
account
andident
params in several account-based RPCs are strings. If not, it returnsinvalidParams
. Some error messages are also improved to be more specific.Note: This PR looks a lot larger than it is; it is really just the same change(s) applied over and over again across several RPCs.
Context of Change
rippled currently returns
Internal error
in this scenario.The error in the logs is
Caught throw: Type is not convertible to string
Type of Change
API Impact
libxrpl
change (any change that may affectlibxrpl
or dependents oflibxrpl
)This is a bugfix, not a breaking change, but there isn't an option for that.
Test Plan
Added unit tests that fail before this patch and now pass.
Future Tasks
Audit other RPCs for this sort of issue.