Fix null id in RPC response during startup #6362

Merged
merged 1 commit into from Jul 2, 2015

Conversation

Projects
None yet
3 participants
@forrestv
Contributor

forrestv commented Jul 2, 2015

When processing RPC commands during warmup phase, parse the
request object before returning an error so that id value can
be used in the response.

Prior to this commit, RPC commands sent during Bitcoin's
warmup/startup phase were responded to with a JSON-RPC error
with an id of null, which violated the JSON-RPC 2.0 spec:

id: This member is REQUIRED. It MUST be the same as the value
of the id member in the Request Object. If there was an error
in detecting the id in the Request object (e.g. Parse
error/Invalid Request), it MUST be Null.

When processing RPC commands during warmup phase, parse the
request object before returning an error so that id value can
be used in the response.

Prior to this commit, RPC commands sent during Bitcoin's
warmup/startup phase were responded to with a JSON-RPC error
with an id of null, which violated the JSON-RPC 2.0 spec:

id: This member is REQUIRED. It MUST be the same as the value
of the id member in the Request Object. If there was an error
in detecting the id in the Request object (e.g. Parse
error/Invalid Request), it MUST be Null.

@laanwj laanwj added the RPC/REST/ZMQ label Jul 2, 2015

@laanwj

This comment has been minimized.

Show comment
Hide comment
@laanwj

laanwj Jul 2, 2015

Member

Good catch. The new place is better in any case because this also catches other invocations of CRPCTable::execute, such as from the GUI.

Tested ACK.

Member

laanwj commented Jul 2, 2015

Good catch. The new place is better in any case because this also catches other invocations of CRPCTable::execute, such as from the GUI.

Tested ACK.

@jonasschnelli

This comment has been minimized.

Show comment
Hide comment
@jonasschnelli

jonasschnelli Jul 2, 2015

Member

utACK.
If I'm right, the REST interface does also check if the we are in warmup phase. Because moving the warmup check will also affect REST.

Member

jonasschnelli commented Jul 2, 2015

utACK.
If I'm right, the REST interface does also check if the we are in warmup phase. Because moving the warmup check will also affect REST.

@laanwj

This comment has been minimized.

Show comment
Hide comment
@laanwj

laanwj Jul 2, 2015

Member

@jonasschnelli the code is moved from HTTPReq_JSONRPC to CRPCTable::execute, both is downstream from REST/HTTP selection, so RESTS cannot be affected. REST should do its own check and raise its own error, which has nothing to do with JSONRPCError.

Here's the same check for REST: https://github.com/bitcoin/bitcoin/blob/master/src/rest.cpp#L556

Member

laanwj commented Jul 2, 2015

@jonasschnelli the code is moved from HTTPReq_JSONRPC to CRPCTable::execute, both is downstream from REST/HTTP selection, so RESTS cannot be affected. REST should do its own check and raise its own error, which has nothing to do with JSONRPCError.

Here's the same check for REST: https://github.com/bitcoin/bitcoin/blob/master/src/rest.cpp#L556

@jonasschnelli

This comment has been minimized.

Show comment
Hide comment
@jonasschnelli

jonasschnelli Jul 2, 2015

Member

Sorry. Right, there are no changes for REST calls.

Member

jonasschnelli commented Jul 2, 2015

Sorry. Right, there are no changes for REST calls.

@laanwj laanwj merged commit 72b9452 into bitcoin:master Jul 2, 2015

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

laanwj added a commit that referenced this pull request Jul 2, 2015

Merge pull request #6362
72b9452 When processing RPC commands during warmup phase, parse the request object before returning an error so that id value can be used in the response. (Forrest Voight)

luke-jr added a commit to luke-jr/bitcoin that referenced this pull request Jan 10, 2016

When processing RPC commands during warmup phase, parse the
request object before returning an error so that id value can
be used in the response.

Prior to this commit, RPC commands sent during Bitcoin's
warmup/startup phase were responded to with a JSON-RPC error
with an id of null, which violated the JSON-RPC 2.0 spec:

id: This member is REQUIRED. It MUST be the same as the value
of the id member in the Request Object. If there was an error
in detecting the id in the Request object (e.g. Parse
error/Invalid Request), it MUST be Null.

Github-Pull: #6362
Rebased-From: 72b9452

luke-jr added a commit to luke-jr/bitcoin that referenced this pull request Jan 10, 2016

When processing RPC commands during warmup phase, parse the
request object before returning an error so that id value can
be used in the response.

Prior to this commit, RPC commands sent during Bitcoin's
warmup/startup phase were responded to with a JSON-RPC error
with an id of null, which violated the JSON-RPC 2.0 spec:

id: This member is REQUIRED. It MUST be the same as the value
of the id member in the Request Object. If there was an error
in detecting the id in the Request object (e.g. Parse
error/Invalid Request), it MUST be Null.

Github-Pull: #6362
Rebased-From: 72b9452

@str4d str4d referenced this pull request in zcash/zcash Feb 14, 2017

Merged

Bitcoin 0.12 RPC PRs 1 #2100

@dagurval dagurval referenced this pull request in bitcoinxt/bitcoinxt Mar 18, 2017

Merged

rpc: Accept strings in AmountFromValue #191

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment