Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

get_block api call returns incorrect http code for unknown block #6374

Closed
mlockett42 opened this issue Nov 22, 2018 · 3 comments
Closed

get_block api call returns incorrect http code for unknown block #6374

mlockett42 opened this issue Nov 22, 2018 · 3 comments

Comments

@mlockett42
Copy link

Calling get_block for an unknown block - typically one with a block number greater than the head block number.

curl --request POST --url https://node2.eosphere.io/v1/chain/get_block --data '{"block_num_or_id":"100000000"}'

Returns http result code 500, the correct http result code to return in this situation is 404.

500 indicates an Internal Server Error, 404 "indicates that the origin server did not find a current representation for the target resource"

404 seems to more accurately reflect the reality of asking for a block that does not exist.

@jgiszczak
Copy link
Contributor

This does not seem like a correct change.

Code 404 means "The server has not found anything matching the Request-URI." When a requested block does not exist, the Request-URI, namely /v1/chain/get_block is still correct. Only the data payload is incorrect.

Per RFC 4918, the most applicable code is 422. However in proposed standard changes, RFC 7231 revises the definition of code 400, making that the best choice.

Given that HTTP/1.1 incorporated some of 7231, I would prefer to see code 400.

@jgiszczak
Copy link
Contributor

#6490 merged and incorporated into v1.6.0 release candidate.

@iamveritas
Copy link
Contributor

iamveritas commented Jan 18, 2019

Code 404 means "The server has not found anything matching the Request-URI."

I could not find this in any of the RFC. Instead I could find this "The 404 (Not Found) status code indicates that the origin server did not find a current representation for the target resource or is not willing to disclose that one exists."

According to this definition, the whole request (uri + payload) points to "the target resource", right?
404 (not found) seems more natural in this case, you are looking for something which is not there, it doesn't exist, not because the uri or payload is wrong formatted.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants