rpc: Fail to return undocumented return values#20459
Conversation
|
Concept ACK but it would be much better if checks like this could be done at compile time instead of run time. This seems to me like a kind of a python-esque solution instead of a static language one. |
|
UniValue::getType() is not a compile-time constant, so I don't think this works at compile time (without replacing UniValue with something else) |
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsNo conflicts as of last run. |
|
concept ACK, very nice! having a programatic check that the docs are in sync with the actual output seems like a win for maintaining up-to-date docs & reducing review burden |
src/rpc/util.cpp
Outdated
| return UniValue::VSTR == result.getType(); | ||
| } | ||
| case Type::NUM: | ||
| case Type::NUM_AMOUNT: |
There was a problem hiding this comment.
Suggestion for a follow-up: for NUM_AMOUNT, you can do a stronger test (parse with AmountFromValue, convert back to JSON using ValueFromAmount, and the string representation must match exactly).
faba446 to
fabf051
Compare
Currently a few return values are undocumented. This is causing confusion at the least. See for example #18476
Fix this by treating it as an internal bug to return undocumented return values.