KeyError with non-existent repositories (hgwebdir.cgi)

Maxim Khitrov mkhitrov at gmail.com
Sat Jul 14 15:14:37 CDT 2007


On 7/14/07, Brendan Cully <brendan at kublai.com> wrote:
> On Saturday, 14 July 2007 at 15:27, Maxim Khitrov wrote:
> > Hello,
> >
> > I'm trying to configure hgwebdir.cgi script to serve a few of my
> > repositories via Lighttpd. I'm using rewrite rules to send all
> > requests to the cgi script, and the whole thing works great for the
> > repositories that are there.
> >
> > My question is about requests for non-existent directories. If I try
> > to access some random path that does not point to a valid repository,
> > I get a KeyError message with a ton of output containing the call
> > trace. My problem with this is that it exposes all the relevant paths
> > on the server. Where hgwebdir.cgi is running from, where python is
> > installed, and so on. I'm curious to know if there is some way to
> > suppress this output? For example, just send a 404 error instead.
>
> You are probably running the hgwebdir gitweb style? It was missing the
> 'notfound' template for a long time. It was fixed about a week ago in
> d39776752a1f.

Indeed I am. I tried commenting out cgitb.enable() as Matt suggested
before I got your message and that method worked fine.

Following your suggestion, I also downloaded the latest gitweb
template. While the new version does display the 'not found' error, it
has a bit of a problem with css style. The URL it generates for the
not found error css contains the missing repository name. That has to
be removed, otherwise you just get another not found error for the
style sheet. Other than that it works exactly as it should.

I'm going to stick with the cgitb.enable() method, because there are
actually a few more errors that I found. For example, if you create a
brand new repository (hg init) and allow bz2 or zip archives, both of
those operations fail with an IndexError. Minor issue, but should
still probably be fixed (download an empty archive) in the future
release. Until then I'll disable all error reporting.

Thanks for your help guys!


More information about the Mercurial mailing list