过期实体的 REST API 服务向 return 发送的适当 HTTP 状态代码是什么?

What's an appropriate HTTP status code to return by a REST API service for an expired entity?

假设我们有一家在线商店并收到更新某些订单的有效请求。

请求本身是有效的,但是假设订单有过期时间,而且已经过期了,所以这个请求实际上是无法处理的。

我怀疑这是否是一种验证错误。因为,正如我上面所说,请求本身是有效的;并且请求发送者可能不知道订单已经过期。

在这种情况下,REST API 服务向 return 发送的适当 HTTP 状态代码是什么?

警告:由于对产品的一般要求,应该是一些4XX错误代码!

UPD:更多信息:这个推定的 "order" 仍然存在,甚至已经过期。可以取回它,但不能再操作它。这就是代码 404(例如)不合适的原因。

我自己的版本:

我认为对于这种情况,410 status code是最合适的:

The 410 response is primarily intended to assist the task of web
maintenance by notifying the recipient that the resource is
intentionally unavailable and that the server owners desire that
remote links to that resource be removed. Such an event is common
for limited-time, promotional services and for resources belonging to individuals no longer associated with the origin server's site. It
is not necessary to mark all permanently unavailable resources as
"gone" or to keep the mark for any length of time -- that is left to
the discretion of the server owner.

https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html:

The requested resource is no longer available at the server and no forwarding address is known. This condition is expected to be considered permanent. Clients with link editing capabilities SHOULD delete references to the Request-URI after user approval. If the server does not know, or has no facility to determine, whether or not the condition is permanent, the status code 404 (Not Found) SHOULD be used instead. This response is cacheable unless indicated otherwise

使用410 Gone.

The target resource is no longer available at the origin server and that this condition is likely to be permanent.

我会选择其中之一: 400 - 错误请求 410 - 走了

来自 : https://en.wikipedia.org/wiki/List_of_HTTP_status_codes

我会说 400410 更合适。

IMO 410 (Gone) 不适合,因为资源 没有 消失。它仍然存在,只是某种最终(在本例中 expired)状态。

400表示BadRequest。根据我的解释,尝试 UPDATE 不可更新的东西(尝试更新 expired 项目)是 BadRequest.

我相信,400 不仅适用于格式错误的请求,还适用于不符合内部业务逻辑验证的请求(在这种情况下,不更新 expired 项目,是内部业务逻辑)。