[Devel] Recent spate of errors
Raphael Krut-Landau
raphael at openhatch.org
Wed Jun 16 02:28:08 UTC 2010
On Tue, Jun 15, 2010 at 9:19 PM, Asheesh Laroia <asheesh at openhatch.org> wrote:
> Excerpts from Raphael Krut-Landau's message of Sun Jun 13 21:36:33 +0000 2010:
>> Devs,
>>
>> Here's a report on today's flurry of error emails. The code path that
>> generated the errors was roughly this:
>>
>> * Citation.get_url_or_guess was trying to urlencode a project name,
>> * and the project name when retrieved from the database was coming out
>> as a string, not as unicode.
>> * Our urlencode wrapper was wired to set a pdb trace when it receives
>> a non-unicode string as an argument.
>> * We can't set a pdb trace on the live site, and the consequence was a
>> sort of IOError.
>>
>> I've added two fixes. First, encode the project name as unicode before
>> passing it to urlencode. This is the "correct way".
>
> I thought I pushed a fix for this, too. Glad to see you saw it too!
Weird. The site was definitely going splody when I wrote a fix for
this. Maybe the deploy script fudged for you? At any rate, my
apologies if I duplicated work you had already done.
>> But just to be safe, I've also implemented a second fix, i.e., a bit
>> of graceful degradation:
>> * Don't set a pdb trace when urlencode receives a non-unicode string,
>> but just throw a ProgrammingError (for a lack of a better error
>> class-- I was writing this pretty quickly since the site was
>> exploding.)
>> * Citation.get_url_or_guess is now configured so that if *any*
>> exception (ProgrammingError or otherwise) is thrown while urlencoding,
>> we don't use our kinky urlencode wrapper, but instead just attempt to
>> encode the project name using the vanilla urllib.urlencode function.
>> When this degradation happens, we print a message using logging.warn,
>> which I believe appears in one of the error logs.
>
> ProgrammingError is basically only for SQL...
Yeah... sorry. I know it's not the right Exception class. I was
writing this in a massive hurry; I just needed some sort of Exception.
>> A question for Asheesh: Why wasn't this failing before? That is, was
>> citation.portfolio_entry.project.name really giving us unicode before,
>> but now giving us a string?
>
> Because we're now on Python 2.6! Yay!
>
> Only, random things are different and I don't know why! Boo!
Fie on Python 2.6. You've probably already thought of this, but for
the next Python upgrade, I would advise sitting next to the server for
a bit to see if stuff starts to catch fire.
--Raffi.
More information about the Devel
mailing list