git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] gitweb: return correct HTTP status codes

From
Jakub Narebski <jnareb@gmail.com>
Date
Jun 16, 2008, 22:34 UTC
Message-ID
<200806170034.42621.jnareb@gmail.com>
In-Reply-To
<4856DFE8.9010809@gmail.com>
On Mon, 16 Jun 2008, Lea Wiemann wrote:
Show 7 quoted lines
> Jakub Narebski wrote:
>>
>> Well, we could, perhaps, examine stderr (or redirect it to stdout and
>> examine upon error) to check what was the error.
> 
> We don't have to -- gitweb's current (suboptimal) error checking is 
> because it doesn't interface with git very well.

The "examine stderr" was a bit tongue-in-cheek, i.e. solution which would require least changes... but I guess very impractical.

> The API I'm writing  
> will fix this (i.e. provide proper feedback in all cases) so we'll have 
> more specific status codes.  IOW, we'll be able to differentiate between 
> 500 and 404.  Trust me on this one. ;-)

I have thought that Git.pm API together with catching (and examining) Error, perhaps with redirecting STDERR somewhere (but it would be best if it would not be needed) would be enough.

Show 10 quoted lines
>> But I think in all, or almost all cases, the source is wrong parameters
>> in URL.  Now, returning 5xx _server_ error would make me want to email
>> webmaster about error on his/her server, while 4xx _user_ error would
>> make me examine my input
> 
> Since the status codes will get better (more accurate) anyway, I care 
> more about correctness than practicalities right now (and I'm convinced 
> that only 500 is correct in the cases we're talking about).  That said, 
> if you really want 404s in there, go ahead and send a follow-up patch, I 
> won't object.

If the source of error is some misconfiguration on server, then 5xx is appropriate (for example git binary is not found, something which perhaps we should check upfront at the beginning). But I think it should be very, very rare, and result of misconfigured gitweb, or error installing git... or corrupted repository.

If source of error is mistake in URL, I would certainly want 4xx error. So the user knows that he/she has to look at the URL.

That said, perhaps I am worrying over nothing, and
  or die_error(undef, "Open <git command> failed");
can happen only on some serious server error (like corrupted
repository).
>From RFC 2616 (http://tools.ietf.org/html/rfc2616)
 10.4 Client Error 4xx
   The 4xx class of status code is intended for cases in which the
   client seems to have erred.
 [...]
 10.5 Server Error 5xx
   Response status codes beginning with the digit "5" indicate cases in
   which the server is aware that it has erred or is incapable of
   performing the request.
 
Show 5 quoted lines
>> BTW. I got three copies of this email: was it you fighting VGER
>> anti-spam filter?
> 
> Yup.  Apparently it simply greps for Content-TypXe: text/hXtml.  *shakes 
> head* :-)

It is unfortunately very simple pattern based filter, not Markovian, spam/ham Bayesian, or even simple Bayesian.

-- 
Jakub Narebski
Poland
Previous: Lea WiemannNext: Lea Wiemann
Message 6 of 25 in “gitweb: return correct HTTP status codes”
  1. gitweb: return correct HTTP status codesLea Wiemann, Jun 15, 2008
  2. Jakub NarebskiJun 15, 2008
  3. Lea WiemannJun 16, 2008
  4. Jakub NarebskiJun 16, 2008
  5. Lea WiemannJun 16, 2008
  6. Jakub NarebskiJun 16, 2008
  7. Lea WiemannJun 17, 2008
  8. Junio C HamanoJun 16, 2008
  9. Lea WiemannJun 17, 2008
  10. Jakub NarebskiJun 17, 2008
  11. Lea WiemannJun 17, 2008
  12. Jakub NarebskiJun 17, 2008
  13. Lea WiemannJun 17, 2008
  14. Jakub NarebskiJun 18, 2008
  15. Lea WiemannJun 18, 2008
  16. Jakub NarebskiJun 18, 2008
  17. Jakub NarebskiJun 16, 2008
  18. gitweb: standarize HTTP status codesLea Wiemann, Jun 18, 2008
  19. Jakub NarebskiJun 19, 2008
  20. Lea WiemannJun 19, 2008
  21. gitweb: standarize HTTP status codesLea Wiemann, Jun 19, 2008
  22. gitweb: standarize HTTP status codesLea Wiemann, Jun 19, 2008
  23. Jakub NarebskiJun 19, 2008
  24. Junio C HamanoJun 20, 2008
  25. Jakub NarebskiJun 19, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.