internal error trying to serve HEAD

Bug #732481 reported by John A Meinel on 2011-03-10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Launchpad itself
John A Meinel

Bug Description

root: - - [10/Mar/2011:10:08:32 +0000] "HEAD /%7Evcs-imports/busybox/main/changes HTTP/1.0" 200 - "-" "-"
INF [20110310-10:08:32.545] [47191873160960] loggerhead: Processed ok [0.440 seconds]
ERR [20110310-10:08:32.546] [47191873160960] root: Traceback (most recent call last):
ERR [20110310-10:08:32.546] [47191873160960] root: File "/srv/", line 1062, in process_request_in_thread
ERR [20110310-10:08:32.546] [47191873160960] root: self.finish_request(request, client_address)
ERR [20110310-10:08:32.546] [47191873160960] root: File "/usr/lib/python2.6/", line 320, in finish_request
ERR [20110310-10:08:32.546] [47191873160960] root: self.RequestHandlerClass(request, client_address, self)
ERR [20110310-10:08:32.546] [47191873160960] root: File "/usr/lib/python2.6/", line 615, in __init__
ERR [20110310-10:08:32.546] [47191873160960] root: self.handle()
ERR [20110310-10:08:32.547] [47191873160960] root: File "/srv/", line 436, in handle
ERR [20110310-10:08:32.547] [47191873160960] root: BaseHTTPRequestHandler.handle(self)
ERR [20110310-10:08:32.547] [47191873160960] root: File "/usr/lib/python2.6/", line 329, in handle
ERR [20110310-10:08:32.547] [47191873160960] root: self.handle_one_request()
ERR [20110310-10:08:32.547] [47191873160960] root: File "/srv/", line 431, in handle_one_request
ERR [20110310-10:08:32.547] [47191873160960] root: self.wsgi_execute()
ERR [20110310-10:08:32.547] [47191873160960] root: File "/srv/", line 292, in wsgi_execute
ERR [20110310-10:08:32.547] [47191873160960] root: self.wsgi_write_chunk('')
ERR [20110310-10:08:32.547] [47191873160960] root: File "/srv/", line 125, in wsgi_write_chunk
ERR [20110310-10:08:32.547] [47191873160960] root: "Content returned before start_response called")
ERR [20110310-10:08:32.547] [47191873160960] root: RuntimeError: Content returned before start_response called

Related branches

John A Meinel (jameinel) wrote :

The first thing that strikes me, is that all of the code is in Paste and Wsgilib, etc. There isn't any Launchpad code here.

My best guess is that we got an exception while processing an exception? Still trying to dig into it.

John A Meinel (jameinel) on 2011-03-10
Changed in loggerhead:
status: New → Triaged
importance: Undecided → High
John A Meinel (jameinel) wrote :

I can reproduce this locally with the Launchpad. Using:

However, I *don't* see this when running Loggerhead using "bzr serve --http". Though that is also using the system wide Paste and simpletal. Tracking it down further.

John A Meinel (jameinel) wrote :

This is also seen when using 'bin/py' from launchpad, and using SIGQUIT to confirm what dependencies are being used. So it looks to be strictly a bug in the Launchpad glue binding around Loggerhead.

John A Meinel (jameinel) wrote :

I think I've isolated the bug, and we just need a bit more direct tests.

The issue is that WrappedStartResponse delays the actual call to start_response() until after stuff has been processed. (Presumably so that it can send an OOPS page if it gets an error from the time start_response is called, to the point where content actually starts streaming.)

However, if the app doesn't return any content, then this is the loop:
           while True:
                    data =
                except StopIteration:
                if not wrapped.body_started:
                yield data

This happened when I consolidated the code paths between the various try/except OOPS logic. (Though it might have had the bug as well).

We didn't notice until this deployment, because loggerhead was still generating body content for HEAD. Once we started deploying the new loggerhead (this release), it stopped generating body content, so this check broke.

One option is to add a try/finally to make sure that wrapped.really_start() is always called if start_response has been called. I'll poke at it a bit to make sure things look decent, and I'll try to add some paste interactions to make sure we catch this.

Changed in launchpad:
status: Triaged → In Progress
John A Meinel (jameinel) wrote :

Not actually a bug in loggerhead. We ran into this because of deploying a loggerhead that stopped writing BODY content for a HEAD request, which exposed a bug in our oops_middleware logic when there is no BODY content.

Changed in loggerhead:
status: Triaged → Invalid
Launchpad QA Bot (lpqabot) wrote :
Changed in launchpad:
milestone: none → 11.04
tags: added: qa-needstesting
Changed in launchpad:
status: In Progress → Fix Committed
John A Meinel (jameinel) wrote :

Can't qa this because Loggerhead doesn't run correctly on qastaging. :(

tags: added: qa-untestable
removed: qa-needstesting
Changed in launchpad:
status: Fix Committed → Fix Released

Hash: SHA1

On 3/15/2011 1:01 AM, Robert Collins wrote:
> ** Changed in: launchpad
> Status: Fix Committed => Fix Released

Confirmed. Just sent a HEAD request to

And it came back HTTP 200 OK instead of HTTP 500 Internal Server Error.


Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla -


To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers