Skip to content

rpc: Fix addnode remove command error#19696

Merged
laanwj merged 1 commit intobitcoin:masterfrom
fjahr:rpc_net_tests
Aug 12, 2020
Merged

rpc: Fix addnode remove command error#19696
laanwj merged 1 commit intobitcoin:masterfrom
fjahr:rpc_net_tests

Conversation

@fjahr
Copy link
Copy Markdown
Contributor

@fjahr fjahr commented Aug 10, 2020

The addnode RPC with the remove command parameter is used to remove a node from the "added nodes". It did not have test coverage and in case of failure to remove the node it responded with the confusing message "Error: Node has not been added.".

This PR adds test coverage and introduces a new error code as well as changes the error message to something that makes sense.

Copy link
Copy Markdown
Member

@jonatack jonatack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested ACK 9795d93ab445c0e

Feel free to ignore the comments below unless you have to retouch.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps place this test (or all the new ones) two lines higher as it is order-dependent on the addnode call.

s/can not/cannot/

@maflcko
Copy link
Copy Markdown
Member

maflcko commented Aug 11, 2020

I think the previous error was fine. Can't remove node, because node has not been added. No strong opinion, though.

Concept ACK on adding test coverage here: https://marcofalke.github.io/btc_cov/total.coverage/src/rpc/net.cpp.gcov.html#274

@jonatack
Copy link
Copy Markdown
Member

I agree with @fjahr that this error message is confusing. Good idea on adding the missing coverage; thank you for reminding me of your btc_cov link.

@maflcko
Copy link
Copy Markdown
Member

maflcko commented Aug 11, 2020

If the change stays, it needs release notes, because it is a breaking RPC change

@promag
Copy link
Copy Markdown
Contributor

promag commented Aug 11, 2020

Agree with @MarcoFalke, the change in the error isn't worth a breaking change. I'd rather document the error.

On a side note, instead of raising RPC errors, I'd return { "message": "node not found" } or something like that.

This also adds test coverage for the remove command which was uncovered before.
@fjahr
Copy link
Copy Markdown
Contributor Author

fjahr commented Aug 11, 2020

I was not sure but I assume changing the error code is breaking but changing the error message is not considered breaking? I have changed the error code back and kept an improved error message that should explain the reasoning behind the error code better. Also addressed @jonatack 's nits.

Copy link
Copy Markdown
Contributor

@theStack theStack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the confusing part in the error message was that "not added" could be possibly interpreted here both as an action/verb (i.e. "didn't add node in the course of this RPC call") as well as referring to a state (i.e. "is currently not in the list of added nodes"). It is clearer now that the latter is meant, and increasing test coverage is always a good idea.

Tested ACK a51d0ad2de

@luke-jr
Copy link
Copy Markdown
Member

luke-jr commented Aug 11, 2020

IMO changes to the string description shouldn't be considered a breaking change.

Copy link
Copy Markdown
Member

@luke-jr luke-jr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

@laanwj
Copy link
Copy Markdown
Member

laanwj commented Aug 12, 2020

IMO changes to the string description shouldn't be considered a breaking change.

I agree here.

Code review ACK a51d0ad

@laanwj laanwj merged commit 13c4635 into bitcoin:master Aug 12, 2020
@maflcko
Copy link
Copy Markdown
Member

maflcko commented Aug 12, 2020

In a previous version the error code (integer) was also changed. Changing the error code has usually been considered a breaking change

Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Sep 8, 2021
Summary:
This also adds test coverage for the remove command which was uncovered before.

PR description:
> The `addnode` RPC with the `remove` command parameter is used to remove a node from the "added nodes". It did not have test coverage and in case of failure to remove the node it responded with the confusing message "Error: Node has not been added.".
> This PR adds test coverage as well as changes the error message to something that makes sense.

This is a backport of [[bitcoin/bitcoin#19696 | core#19696]]

Test Plan: `ninja all check-all`

Reviewers: #bitcoin_abc, majcosta

Reviewed By: #bitcoin_abc, majcosta

Differential Revision: https://reviews.bitcoinabc.org/D10072
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants