Repository navigation
Description
(cloning tendermint/tendermint#10020)
Bug Report
Setup
CometBFT version (use cometbft version or git rev-parse --verify HEAD if installed from source): Tendermint 0.34.23
Have you tried the latest version: no
ABCI app (name for built-in, URL for self-written if it's publicly available): https://main.rpc.agoric.net/
What happened?
A GET /abci_query request with path query parameter as documented at https://docs.cometbft.com/v0.37/rpc/#/ABCI/abci_query (i.e., starting with "/") is rejected:
$ curl -sS 'https://main.rpc.agoric.net/abci_query?path=/custom/vstorage/data/activityhash'
{
"jsonrpc": "2.0",
"id": -1,
"error": {
"code": -32602,
"message": "Invalid params",
"data": "error converting http params to arguments: invalid character '/' looking for beginning of value"
}
}Wrapping that path in double quote characters (as at https://github.com/cometbft/cometbft/blob/main/spec/rpc/README.md#abciquery but without the unexpected =IHAVENOIDEA) works:
$ curl -sS 'https://main.rpc.agoric.net/abci_query?path="/custom/vstorage/data/activityhash"'
{
"jsonrpc": "2.0",
"id": -1,
"result": {
"response": {
"code": 0,
"log": "",
"info": "",
"index": "0",
"key": null,
"value": "ewogICJ2YWx1ZSI6ICIyYTk5YmU3NTIwNTk0MTg5MjlkODExYTA0ZGVlYTE4YjM3NGI3M2IxNTA3Y2ZkMjY2NTYwYzVlYWIwMWViOTk4Igp9",
"proofOps": null,
"height": "9225800",
"codespace": ""
}
}
}So does submitting the entire request as POSTed JSON-RPC:
$ curl -sS https://main.rpc.agoric.net --request POST --header 'Content-Type: application/json' --data \
'{ "jsonrpc": "2.0", "id": -1, "method": "abci_query", "params": { "path": "/custom/vstorage/data/activityhash" } }'
{
"jsonrpc": "2.0",
"id": -1,
"result": {
"response": {
"code": 0,
"log": "",
"info": "",
"index": "0",
"key": null,
"value": "ewogICJ2YWx1ZSI6ICI2MDMzMDJmZmFlNTVjYmFmYjFiZWE2ZTZmM2E4Y2IxZWU0NGI3ZDBkZGFlYjUzZmE5OTkxMDFiMzcxMzJlOGY3Igp9",
"proofOps": null,
"height": "9225809",
"codespace": ""
}
}
}What did you expect to happen?
I expected the unquoted path URL query parameter value to be accepted as documented at https://docs.tendermint.com/v0.34/rpc/#/ABCI/abci_query , rather than rejected for not being JSON.
How to reproduce it
See above.
Logs
n/a
dump_consensus_state output
n/a
Anything else we need to know
The culprit is likely httpParamsToArgs, which has not changed since tendermint/tendermint#4968 was merged in 2020.
Activity
adizere commentedon Apr 27, 2023
Thanks Richard @gibson042 for filing this, great catch! Seems also relatively easy to fix, though it needs a bit more investigation to find the root cause (likely in a method called from the one you mentioned httpParamsToArgs).
stevenferrer commentedon May 21, 2023
Hi @adizere and @gibson042,
As per my investigation, the handling of
pathargument is handled by this line where jsonStringToArg tries to parse thepathvalue as a JSON.As I understand, the
pathshould be handled bynonJSONStringToArgin this line since it's an unquoted string. I submitted a PR #864 to try and fix it, please lemme know your thoughts, thanks!stevenferrer commentedon May 22, 2023
It seems one test failed because it expects that unquoted strings should error. Just wondering if this assumption still holds true? If not, then maybe we can safely update the test to not expect an error, thoughts?
sergio-mena commentedon Jun 16, 2023
Taking a look at the backlog for this
gibson042 commentedon Jun 18, 2023
Looking at Using CometBFT: Formatting, this appears to be intentional (at least for transactions). If so, the issue could be resolved by updating documentation to clarify—the URLs would be unfortunately ugly, but at least the interface would be clear.
sergio-mena commentedon Jun 22, 2023
Analysis
I took a look at the way different types are handled or over our RPC. This is what I found out:
v0.34.x, string-like parameters can be (internally) defined as two types:stringand[]byteabci_query:pathisstring,datais[]bytebroadcast_tx_*:txis[]byteblock_by_hash:hashis[]bytecheck_tx:txis[]bytetx:hashis[]bytetx_search:queryisstring,order_byisstringblock_search:queryisstring,order_byisstringSo, as you can see, parameters
queryandorder_byin endpointstx_searchandblock_searchare the only endpoints comparable to parameterpathinabci_query(in that they are internally typedstring).Testing
This is how these three commands behave when double quotes are not used (they all fail). The behavior is consistent.
And this is how the commands behave when double quotes are used. The behavior is also consistent.
Conclusion
The behavior reported in this issue is the expected one. We can therefore confirm this is a documentation issue.
stevenferrer commentedon Jun 22, 2023
Hi @sergio-mena, thanks for the detailed analysis. I submitted PR #1015 to update the rpc/openapi spec to add double quotes to
pathparam. Please let me know if there are other places that needs to be updated, thanks!sergio-mena commentedon Jun 22, 2023
Thanks a lot @stevenferrer, for filing #1015. We will take it from there. We will check all over ours docs, to make sure any example for one of those endpoints contains the double quotes
alijnmerchant21 commentedon Jun 23, 2023
Thanks - @stevenferrer for filing PR #1015. I have made some changes, reflected in the commit.
Also made a PR #1020 to reflect changes on
0.34docs: Added double quotes to /abci_query path param (#1015)
docs: Added double quotes to /abci_query path param (#1015)
docs: Added double quotes to /abci_query path param (#1015)
docs: Added double quotes to /abci_query path param (#1015)
docs: Added double quotes to /abci_query path param (#1015) (#1046)
docs: Added double quotes to /abci_query path param (#1015) (#1045)
docs: Added double quotes to /abci_query path param (#1015) (#1047)
Merge main to abci-tutorial (#1372)
docs: Added double quotes to /abci_query path param (cometbft#1015) (c…