Re: Generic semantics for the 400 status code

Willy Tarreau <w@1wt.eu> Fri, 15 July 2011 13:52 UTC

Return-Path: <ietf-http-wg-request@listhub.w3.org>
X-Original-To: ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com
Delivered-To: ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id F3D4B21F8778 for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Fri, 15 Jul 2011 06:52:50 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -10.434
X-Spam-Level:
X-Spam-Status: No, score=-10.434 tagged_above=-999 required=5 tests=[AWL=0.165, BAYES_00=-2.599, RCVD_IN_DNSWL_HI=-8]
Received: from mail.ietf.org ([64.170.98.30]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id J28J3rCi7heb for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Fri, 15 Jul 2011 06:52:50 -0700 (PDT)
Received: from frink.w3.org (frink.w3.org [128.30.52.56]) by ietfa.amsl.com (Postfix) with ESMTP id 5D08B21F85FE for <httpbisa-archive-bis2Juki@lists.ietf.org>; Fri, 15 Jul 2011 06:52:50 -0700 (PDT)
Received: from lists by frink.w3.org with local (Exim 4.69) (envelope-from <ietf-http-wg-request@listhub.w3.org>) id 1QhioU-0001fz-Mg for ietf-http-wg-dist@listhub.w3.org; Fri, 15 Jul 2011 13:52:18 +0000
Received: from aji.keio.w3.org ([133.27.228.206]) by frink.w3.org with esmtp (Exim 4.69) (envelope-from <w@1wt.eu>) id 1QhioL-0001f3-Iw for ietf-http-wg@listhub.w3.org; Fri, 15 Jul 2011 13:52:09 +0000
Received: from 1wt.eu ([62.212.114.60]) by aji.keio.w3.org with esmtp (Exim 4.72) (envelope-from <w@1wt.eu>) id 1QhioG-0008Fj-3E for ietf-http-wg@w3.org; Fri, 15 Jul 2011 13:52:08 +0000
Received: (from willy@localhost) by mail.home.local (8.14.4/8.14.4/Submit) id p6FDpXuG027744; Fri, 15 Jul 2011 15:51:33 +0200
Date: Fri, 15 Jul 2011 15:51:33 +0200
From: Willy Tarreau <w@1wt.eu>
To: Mark Nottingham <mnot@mnot.net>
Cc: HTTP Working Group <ietf-http-wg@w3.org>
Message-ID: <20110715135133.GC27520@1wt.eu>
References: <E7DE53B9-C374-4C9B-81D2-1F35BFCC174F@mnot.net>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: inline
In-Reply-To: <E7DE53B9-C374-4C9B-81D2-1F35BFCC174F@mnot.net>
User-Agent: Mutt/1.4.2.3i
Received-SPF: pass client-ip=62.212.114.60; envelope-from=w@1wt.eu; helo=1wt.eu
X-W3C-Hub-Spam-Status: No, score=-1.9
X-W3C-Hub-Spam-Report: BAYES_00=-1.9, RP_MATCHES_RCVD=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001
X-W3C-Scan-Sig: aji.keio.w3.org 1QhioG-0008Fj-3E ab7fdf7ebb6ac53e8cf63d7d10e335ab
X-Original-To: ietf-http-wg@w3.org
Subject: Re: Generic semantics for the 400 status code
Archived-At: <http://www.w3.org/mid/20110715135133.GC27520@1wt.eu>
Resent-From: ietf-http-wg@w3.org
X-Mailing-List: <ietf-http-wg@w3.org> archive/latest/10948
X-Loop: ietf-http-wg@w3.org
Sender: ietf-http-wg-request@w3.org
Resent-Sender: ietf-http-wg-request@w3.org
Precedence: list
List-Id: <ietf-http-wg.w3.org>
List-Help: <http://www.w3.org/Mail/>
List-Post: <mailto:ietf-http-wg@w3.org>
List-Unsubscribe: <mailto:ietf-http-wg-request@w3.org?subject=unsubscribe>
Resent-Message-Id: <E1QhioU-0001fz-Mg@frink.w3.org>
Resent-Date: Fri, 15 Jul 2011 13:52:18 +0000

Hi Mark,

On Fri, Jul 15, 2011 at 10:53:09PM +1000, Mark Nottingham wrote:
> When people have error states that don't cleanly fit into an existing status code, they're often encouraged to use 400 or 500, depending on whether the client or server were at fault, as they're the most "generic" status codes.
> 
> 500's definition fits this:
> 
> > 8.5.1.  500 Internal Server Error
> > 
> >    The server encountered an unexpected condition which prevented it
> >    from fulfilling the request.
> 
> However, 400 is much more specific:
> 
> > 8.4.1.  400 Bad Request
> > 
> >    The request could not be understood by the server due to malformed
> >    syntax.  The client SHOULD NOT repeat the request without
> >    modifications.
> 
> I think the 400 definition needs to be broadened, so that people don't invent their own status codes, or misuse existing ones.
> 
> E.g.,
> 
> """
> The server can or will not process the request, due to a client error (e.g., malformed syntax).
> """
> 
> Additionally, I think we should move the caution against retrying the request to the general 4xx section (8.4)*.
> 
> Background:
>   http://docs.openstack.org/cactus/openstack-compute/developer/openstack-compute-api-1.1/content/Synchronous_Faults-d1e1729.html#comment-213643851
> 
> Thoughts?

I have mixed opinions on this point.

On the one hand, yes we said a server could use 503 + Retry-After for rate
shaping when it's overloaded. However in my opinion this is irrelevant to
the client and it might return that to any request during the overload
period. If the server is refusing to serve a client which is abusing, a 4xx
seems more appropriate, since the cause is this specific client, but I don't
see any existing one which fits the purpose.

I have a principle of always ensuring that a client cannot cause a server
to emit 5xx codes if the server is working correctly. This is important
for someone like me who spends a lot of time staring at gigs of logs,
because when you spot a 5xx, it means something is going wrong with the
server. The only exception I found to this was 501.

So my understanding has always been this :
  - if the request is rejected because of the client, 4xx
  - if the request is rejected regardless of the client, 5xx

The difference is important when intermediaries look at return codes.
Some might want to reduce connection pools to the server when they see
5xx. Some will declare a server down or failing when they see 5xx.

Anyway, in the discussion at the link above, I'm not even sure the user
needs to get a Retry-After : if the client is abusing its contract, then
we don't necessarily want to see him reconnect ASAP when the abuse is
over. Still it can make sense to define one 4xx for client abuse.

Just my 2 cents,
Willy