No error message for wrong command and endless loop #5821

issue benjiqq opened this issue on February 24, 2015
  1. benjiqq commented at 2:12 PM on February 24, 2015: none

    If bitcoind is misconfigured this line produces an endless loop without information to the user what the problem is: https://github.com/bitcoin/bitcoin/blob/master/src/bitcoin-cli.cpp#L213

    An appropriate behaviour would be throwing an error: request not allowed or not known something like that.

  2. laanwj added the label Bug on Feb 24, 2015
  3. ajweiss commented at 9:32 PM on February 24, 2015: contributor

    The purpose of the rpcwait argument is to ask the command line client to wait until it can connect to a running bitcoind so that way test scripts and whatnot don't have to worry about how long it takes a fresh bitcoind to warm up.

    What is the exact misconfiguration you are referring to?

  4. benjiqq commented at 1:09 AM on February 25, 2015: none

    In this case server was not set. From the user's perspective it's a very bad way of dealing with inputs. What I'm supposed to do with this output information? (none) That's what output is there for: to inform a user about the internal state. With no output, I have no way to know what is going on, no way of fixing it. And if something is misconfigured the system should exit. Here it just loops on.

  5. laanwj commented at 8:48 AM on February 25, 2015: member

    Can you specify the exact command line you're using (and the OS)? I've tried various combinations of rpcwait and invalid commands, and cannot reproduce an infinite loop.

    src/bitcoin-cli -testnet -rpcwait test
    error: {"code":-32601,"message":"Method not found"}
    
  6. benjiqq commented at 8:55 AM on February 25, 2015: none

    On Ubuntu 14, tag 0.10.0, if the conf does not contain server=1

    ./bitcoin-cli getinfo
    

    In this case I'd expect an error like "error: server not set." or something like it.

  7. paveljanik commented at 8:59 AM on February 25, 2015: contributor

    Do you run bitcoind or bitcoin-qt (which requires server=1 to enable RPC at all...)?

  8. benjiqq commented at 9:03 AM on February 25, 2015: none

    Running bitcoind.

    If I try to reproduce I get an appropriate error message. So I can't reproduce the problem. Strange - I thought this is default behaviour, because it happened many times.

    bitcoin-cli getinfo
    error: {"code":-28,"message":"Verifying blocks..."}
    

    and if server is down, also a correct error message:

    ./bitcoin-cli getinfo
    error: couldn't connect to server
    
  9. paveljanik commented at 9:14 AM on February 25, 2015: contributor

    I can reproduce endless loop with

    bitcoind -server=0 &
    bitcoin-cli -rpcwait test
    

    but... Ugh. Is it the case you are reporting?

  10. benjiqq commented at 9:24 AM on February 25, 2015: none

    That might be the bug, but without the -rpcwait flag. But you misunderstand some things here: server=0 is not set in versions before 0.10. So it breaks compatibility, because old conf files don't contain server=0. Also an error like this is the responsibility of the person who writes the software, not the user. Blaming users for bad inputs is something you can allow yourself to do in your personal projects. It's like saying if I send -1 bitcoins the software crashes and that's the users fault. No, that's not how error handling and input validation works.

  11. laanwj commented at 9:58 AM on February 26, 2015: member

    Right: The point of -rpcwait is to wait indefinitely until the server comes up. If you didn't start the server then it will wait and wait and wait. It cannot print errors because that will interfere with script usage. Scripts just expect the output, not intermediate status messages.

    Without the -rpcwait flag it should never end up in an infinite loop, though. Anyone else that reproduce this without rpcwait?

  12. laanwj closed this on May 18, 2015

  13. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-29 03:16 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me