This site is an archive; learn more about 8 years of OpenHatch.

[Devel] Recent spate of errors

Raphael Krut-Landau raphael at openhatch.org
Sun Jun 13 21:36:33 UTC 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".

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.

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?

--Raffi.


More information about the Devel mailing list