Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: Come-from-Beyond on September 24, 2013, 08:35:09 AM



Title: Annoying HTTP 500 error
Post by: Come-from-Beyond on September 24, 2013, 08:35:09 AM
I noticed bitcoind loves to respond with HTTP 500 error. I use "gettransaction" via JSON-RPC, it works only for transactions in my own wallet. Bitcoind could return "HTTP 200: I don't give info about someone else transactions" at least.

Even RTFM won't work coz there is no such a thing...


Title: Re: Annoying HTTP 500 error
Post by: Foxpup on September 24, 2013, 10:05:58 AM
Bitcoind could return "HTTP 200: I don't give info about someone else transactions" at least.
No, it couldn't. HTTP 200 means "Your request is valid and I was able to process it correctly, so here's the data you asked for." HTTP 500 is the correct response when the server is unable to carry out your request. What do you expect it to do? Fail to carry out the request and then not give an error? ::)


Title: Re: Annoying HTTP 500 error
Post by: Come-from-Beyond on September 24, 2013, 10:20:46 AM
Bitcoind could return "HTTP 200: I don't give info about someone else transactions" at least.
No, it couldn't. HTTP 200 means "Your request is valid and I was able to process it correctly, so here's the data you asked for." HTTP 500 is the correct response when the server is unable to carry out your request. What do you expect it to do? Fail to carry out the request and then not give an error? ::)

Ok, but it could attach a meaningful description to the 500 response then.


Title: Re: Annoying HTTP 500 error
Post by: davout on September 24, 2013, 10:23:53 AM
What do you expect it to do?

HTTP 422.


Title: Re: Annoying HTTP 500 error
Post by: dserrano5 on September 24, 2013, 02:11:53 PM
There are several 4xx codes that would fit (beginning with the good old 404) but in any case a 5xx isn't appropriate here, in my opinion.


Title: Re: Annoying HTTP 500 error
Post by: DoRob on September 24, 2013, 02:12:50 PM
Error 500 = Internal Server Error


Title: Re: Annoying HTTP 500 error
Post by: davout on September 24, 2013, 02:13:55 PM
There are several 4xx codes that would fit (beginning with the good old 404) but in any case a 5xx isn't appropriate here, in my opinion.

No, 404 is appropriate if the transaction isn't found, as in it does not exist in the blockchain.
422 means "I understand your request, it is legal, but I can not process it for whatever reason".
500 is definitely wrong though, there is no internal error happening, as in "unexpected error".


Title: Re: Annoying HTTP 500 error
Post by: dserrano5 on September 24, 2013, 02:33:04 PM
There are several 4xx codes that would fit (beginning with the good old 404) but in any case a 5xx isn't appropriate here, in my opinion.

No, 404 is appropriate if the transaction isn't found, as in it does not exist in the blockchain.

404 means "Not found here" not "Doesn't exist". A given document may exist but can't be found in the local server, thus 404.


Title: Re: Annoying HTTP 500 error
Post by: davout on September 24, 2013, 02:55:32 PM
There are several 4xx codes that would fit (beginning with the good old 404) but in any case a 5xx isn't appropriate here, in my opinion.

No, 404 is appropriate if the transaction isn't found, as in it does not exist in the blockchain.

404 means "Not found here" not "Doesn't exist". A given document may exist but can't be found in the local server, thus 404.

In this particular context the transaction exists in the DB, it will be properly returned by a getrawtransaction even if it is not a wallet transaction, 404 is not the best return code for this particular context.

404 might be appropriate if the method was named getwallettransaction, not gettransaction OR if the transaction couldn't be found in the general transactions DB.


Title: Re: Annoying HTTP 500 error
Post by: Come-from-Beyond on September 24, 2013, 04:02:27 PM
Guys, the number doesn't matter. I need a description of an error, so I don't need to guess what's happened.