Page MenuHomePhabricator

Gracefully handle server errors on /applications/apply/<random_number>
Closed, ResolvedPublic


When users apply for a partner that's either not available at the moment or not present on the system, handle the error gracefully instead of an internal server error (eg. While not available partners are invisible to non-staff users, they are still capable of entering the partner_ID into the URL (/applications/apply/<that_id>), which then results in a fatal error.

We're likely getting a partner directly by primary key somewhere without first checking whether that partner exists (and is available). We could use the get_object_or_404() function ( to avoid this issue, returning a 404 to the user instead of a server error.

Event Timeline

I would like to work on this task.
Can I get much more information regarding this task?

@rahul-kumi Awesome! I've added another couple of sentences explaining the likely cause of the error and a potential solution.

To get set up with the Library Card platform you should take a look at We have a step-by-step guide in progress at for Windows users. For Linux users, it should be as simple as installing Vagrant and Virtualbox, cloning the repository, and skipping to step 10.

Let me know if you have further questions!

Hi @Samwalton9 , It looks like return type of


is not a QuerySet and doesn't support the .count() method and would have created issue with

assert partners.count() == 1

, so I have opened a PR with a different approach. Could you please check it out here ?