Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the most appropriate HTTP error code for a corrupted payload (checksum failure)?

I'm writing a RESTful API with some endpoints to which clients can PUT or POST chunked files (using flow.js), including a payload digest among the metadata. The server also calculates digest and will throw an error if the digests don't match, in which case the client should attempt to retry the same request with no change (at least until some retry limit is reached).

None of the standard codes seem to fit well by definition. What is the best code to use? Is there any that fits somewhat by convention?

Note: for the purposes of integration with this library, the response must not be 404, 415, 500, or 501 as they will cancel the larger operation rather than retry this portion.

I also cannot use 409 because that is being used to identify attempts to upload multiple copies of the same file, which I believe is a better use of 409 anyway.

like image 689
HonoredMule Avatar asked Feb 26 '16 16:02

HonoredMule


People also ask

What is a 201 status code?

The HTTP 201 Created success status response code indicates that the request has succeeded and has led to the creation of a resource.

What are error codes in HTTP?

HTTP error codes are not part of web pages; instead, they are responses from servers about how the request is handled. Not all HTTP status codes indicate errors. For example, some just communicate that a page has been moved, either permanently or temporarily.

What are some HTTP response codes What does it mean 2xx 3xx 4xx 5xx?

2xx successful – the request was successfully received, understood, and accepted. 3xx redirection – further action needs to be taken in order to complete the request. 4xx client error – the request contains bad syntax or cannot be fulfilled. 5xx server error – the server failed to fulfil an apparently valid request.

What is the difference between 200 and 201 status code?

Perhaps the most common status code returned is 200. It simply means that the request was received, understood, and is being processed, whereas the 201 status code indicates that a request was successful and a resource was created as a result.


1 Answers

I think more appropriate status code when same data from user going wrong, like corrupted data is:

400 Bad Request

For me corrupted data, means like syntax error caused by the transmission of data, semantically correct but syntactically erroneous.

422 Unprocessable Entity maybe apply too. https://www.rfc-editor.org/rfc/rfc4918#section-11.2

like image 65
Steven Koch Avatar answered Sep 30 '22 21:09

Steven Koch