Repository navigation
RPC: make RPCResult::MatchesType return useful errors - #26887
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsReviewers, 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. |
|
eg if I garble up the results of getdeploymentinfo, and run rpc_blockchain.py, prior to this PR, I just get:
with this PR, I instead get: which seems much more helpful for fixing the problem. cc @MarcoFalke |
There was a problem hiding this comment.
Not sure. Wouldn't it be better to use one of the existing checks or formatters from util/check?
There was a problem hiding this comment.
Maybe? Could just use StrFormatInternalBug I guess, but the file/line/func info would be kind of misleading as to where the bug is?
(As it is, it backports cleanly to 24.0, which was convenient for what I was trying to debug)
brunoerg
left a comment
There was a problem hiding this comment.
Concept ACK
It had helped me to save a lot of time recently btw :)
2a92980 to
94adb44
Compare
maflcko
left a comment
There was a problem hiding this comment.
There is one typo. Also, in the presence of bugs it could be confusing to call something "expected". Instead, it could make more sense to just say there is an error and mention the doc-type and the result-type.
ACK 94adb442fac9da04063a57897b44a9623c4fe39e 🔎
Show signature
Signature:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
ACK 94adb442fac9da04063a57897b44a9623c4fe39e 🔎
-----BEGIN PGP SIGNATURE-----
iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUjBLAv+KtPRXStO2Xnup245psxH0FXERsW5S+crdH2b/fqi+vWqAi0KhOXo6BSw
LMANJug1Ynkx+b9Dr8+hBVbTS4EMSHx3LeabuUdVGVPZKBhVV/+PLhT8E0nnCHy9
Yj0c4s+QXkk0Y1bhM7obILGlohrlVRtJ74btQ7ZyUaM7sZnrHAnBr1FkiQvsUA7f
X5TTm1gwC80akEkRRlpf1UkdAjU0O8hrRdg2oIVngj4ADPm03wFAfa3W1b+b0Wyd
wmQgfuzntpAifsZ0KhxA2hBObCmai/7YArkjGnuDMnpi2PnxIk2KxKllCmN6jAOx
fpk+cZ+sHX6XjxFWRnuS7WI2v/NwVe144526u9dK00qAqjwCzHCgwEt1wJm1jqsn
rHELAjaqPkfXGrOnujw08TGeQ+b+FThcxqduTPhfxyFzeB4/lJX+oOKcxcqdjKef
gzxxz/wbJmJEcFCfWbLXE7+bSfX/9hs+XRkv+q75+7TfjNkyhhWM4VYGFOI0EaQl
fRyWhmTw
=3pbv
-----END PGP SIGNATURE-----
94adb44 to
3d1a4d8
Compare
|
Took @MarcoFalke's suggestions (albeit with some wording changes) |
|
Very nice. re-ACK 3d1a4d8 🌷 Show signatureSignature: |
| } | ||
|
|
||
| bool RPCResult::MatchesType(const UniValue& result) const | ||
| static const std::optional<UniValue::VType> ExpectedType(RPCResult::Type type) |
There was a problem hiding this comment.
nit: const is confusing and thus wrong?
Currently if you don't correctly update the description of the return value for an RPC call, you essentially just get an assertion failure with no useful information; this generates a description of the problems instead.