mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 10:50:37 +00:00
rpc: Return the right RPCErrorCode more consistently #36826
No reviewers
Labels
No labels
Android
Backport
Block storage
Brainstorming
Bug
Build system
CI failed
Consensus
Data corruption
Descriptors
Docs
DrahtBot Guix build requested
Feature
Fuzzing
GUI
Good First Review
IPC
Insufficient Review
Kernel
Linux/Unix
Mempool
Mining
Needs Backport (31.x)
Needs Backport (32.x)
Needs Benchmark
Needs Conceptual Review
Needs backport (30.x)
Needs rebase
Needs release note
Net
P2P
PSBT
Privacy
Private Broadcast
Questions and Help
RPC/REST/ZMQ
Refactoring
Resource usage
Review club
Scripts and tools
Settings
TX fees and policy
Tests
Tracking Issue
UTXO Db and Indexes
Up for grabs
Upstream
Utils/log/libs
Validation
Waiting for author
Wallet
Windows
good first issue
interfaces
macOS
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin/bitcoin!36826
Loading…
Reference in a new issue
No description provided.
Delete branch "2611-rpc-errors-consistent"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Currently, rpc code may return the wrong
RPCErrorCode. This is perfectly fine, because they should be hit rarely in production.However, it could be good to be self-consistent. (Otherwise, we could just remove the different error codes and return a single one)
So fix a few error codes:
RPC_TYPE_ERROR, notRPC_MISC_ERRORRPC_INVALID_PARAMETERRPC_MISC_ERRORThe following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
External sites
Reviews
See the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste
<!--meta-tag:bot-skip-->into the comment that the bot should ignore.Conflicts
Reviewers, 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.
LLM Linter (✨ experimental)
Possible places where named args for integral literals may be used (e.g.
func(x, /*named_arg=*/0)in C++, andfunc(x, named_arg=0)in Python):test/functional/feature_fee_estimation.py:assert_raises_rpc_error(-1, "Fee estimation disabled", self.nodes[0].estimatesmartfee, 2)Possible places where comparison-specific test macros should replace generic comparisons:
src/univalue/test/object.cpp:BOOST_CHECK_THROW(v_negative.getInt<uint8_t>(), UniValue::type_error)→ PreferBOOST_CHECK_EXCEPTION(..., UniValue::type_error, HasReason{"JSON integer out of range"}).src/univalue/test/object.cpp:BOOST_CHECK_THROW(v2.getInt<int>(), UniValue::type_error)→ PreferBOOST_CHECK_EXCEPTION(..., UniValue::type_error, HasReason{"<expected type-error message>"}).src/univalue/test/object.cpp:BOOST_CHECK_THROW(v3.getInt<int64_t>(), UniValue::type_error)→ PreferBOOST_CHECK_EXCEPTION(..., UniValue::type_error, HasReason{"JSON integer out of range"}).src/univalue/test/object.cpp:BOOST_CHECK_THROW(v4.getInt<int>(), UniValue::type_error)→ PreferBOOST_CHECK_EXCEPTION(..., UniValue::type_error, HasReason{"JSON integer out of range"}).src/univalue/test/object.cpp:BOOST_CHECK_THROW(vals[0].getInt<int>(), UniValue::type_error)→ PreferBOOST_CHECK_EXCEPTION(..., UniValue::type_error, HasReason{"<expected type-error message>"}).2026-11-12 13:50:40
🔵 Suggestion · Client-visible RPC error-code changes have no release note
Clients that branch on numeric RPC error codes will see changed responses for several failing requests after upgrading, but the PR adds no release note.
Location:
src/univalue/include/univalue.h:150(head).🔵 Suggestion · The new internal-error rule excludes reachable, tested failures
The new “unreachable internal errors” rule conflicts with the pre-existing
loadtxoutsetprecondition errors and its own datadir-corruption example.Location:
src/rpc/protocol.h:60(head).🔵 Suggestion · Several changed error classifications lack targeted assertions
Tests do not pin the changed classifications for invalid
setbancommands, out-of-rangemockschedulerdeltas, double overflow, or the coinstatsindex syncing error.Location:
src/rpc/net.cpp:824(head).Review coverage was incomplete.
Reviewed:
face7839be2b· Review report · Previous reportspermalink
🚧 At least one of the CI tasks failed.
Task
iwyu: https://github.com/bitcoin/bitcoin/actions/runs/43024502508/job/130535654515LLM reason (✨ experimental): CI failed because IWYU/clang-format modified
src/rpc/mining.cpp, causing the clean-diff check to fail.Hints
Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:
Possibly due to a silent merge conflict (the changes in this pull request being
incompatible with the current code in the target branch). If so, make sure to rebase on the latest
commit of the target branch.
A sanitizer issue, which can only be found by compiling with the sanitizer and running the
affected test.
An intermittent issue.
Leave a comment here, if you need help tracking down a confusing failure.
🚧 At least one of the CI tasks failed.
Task
iwyu: https://github.com/bitcoin/bitcoin/actions/runs/43054999350/job/130641963665LLM reason (✨ experimental): CI failed because IWYU modified includes in
src/rpc/external_signer.cpp, leaving a diff that the formatting/lint check rejects.Hints
Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:
Possibly due to a silent merge conflict (the changes in this pull request being
incompatible with the current code in the target branch). If so, make sure to rebase on the latest
commit of the target branch.
A sanitizer issue, which can only be found by compiling with the sanitizer and running the
affected test.
An intermittent issue.
Leave a comment here, if you need help tracking down a confusing failure.
(fixed ralph nit)
tACK
faf54f9c1bTested on macOS 27.2 arm64 (release build) against master
c68583ab5a. The PR'srpc_net.pyfails on master withUnexpected JSONRPC error code -1and passes with this PR.getblockhash 99999999999999999999,getblockhash -99999999999999999999,listtransactions "*" -1,addpeeraddress 1.2.3.4 65536addnode 127.0.0.1:1 abc,setban 1.2.3.4 abc,mockscheduler 0-named echo arg9=trigger_internal_bug-blocksonly)estimatesmartfee 2,estimaterawfee 2getblockhashgetblockhash 1000getblock abchelp getblockhashError messages were identical before and after in all tested error cases; only the codes changed where shown. The node remained running after the simulated internal bug in this release build.
Hmm, I dropped the last three commits on my last push. Maybe they can be done in the future, but for now they are likely not worth the squeeze, as they are ~impossible to review.
tACK
face7839beRepeated all checks from my previous review on macOS 27.2.1 arm64 against master
9183edd25e, after the last three commits were removed. Results are unchanged except:-named echo arg9=trigger_internal_bugnow returns -1 on both master and this PR, consistent with the removed commits.estimaterawfee 2 1e999("JSON double out of range") returns -1 on master and -3 with this PR.The PR's
rpc_net.pystill fails on master and passes with this PR.