HomePhabricator

Reword confusing warning message in RPC linter

Description

Reword confusing warning message in RPC linter

Summary:
It's easy to come across this message by simply forgetting to add an entry
in src/rpc/client.cpp when an argument name matches an existing entry in that table.

This patch clarifies both the intent and reason for the warning, and suggests possible fixes.

Test Plan:
Add this line to commands in src/rpc/avalanche.cpp:
{ "avalanche", "addavalanchepeer", addavalanchepeer, {"nodeid"}},
arc lint src/rpc/avalance.cpp will fail with the warning message (note "nodeid" conflicts with disconnectnode's "nodeid")

Add this line to the table in src/rpc/client.cpp:
{"addavalanchepeer", 0, "nodeid"},
arc lint src/rpc/avalance.cpp passes

Example output:

>>> Lint for /home/jasonbcox/projects/bitcoin-abc:

   Warning  (RPC_MAPPING_WARNING) RPC mapping warning
    In order to keep a consistent API, arguments of the same name are
    expected to either both be string-typed or converted from JSON. But there
    was a conversion mismatch: ["'getavalanchekey' has argument 'nodeid' of
    type 'string'", "'disconnectnode' has argument 'nodeid' of type 'JSON'"].
    Common root causes for this warning: 1) The command and/or argument are
    missing from the conversion table in 'src/rpc/client.cpp'. 2) Arguments
    of the same name are being converted from JSON for some commands, but not
    for others. Consider renaming arguments such that one name is used for
    strings and the other for conversions from JSON.

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Subscribers: deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D5659

Details

Provenance
jasonbcoxAuthored on Apr 2 2020, 19:19
jasonbcoxPushed on Apr 3 2020, 16:31
Reviewer
Restricted Project
Differential Revision
D5659: Reword confusing warning message in RPC linter
Parents
rABCd16ea8ad0e79: depends: Consistent use of package variable
Branches
Unknown
Tags
Unknown