Launchpad should send appropriate error codes instead of 200 all the time

Bug #461901 reported by Leonard Richardson on 2009-10-27
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Launchpad itself
Low
Unassigned
Ubuntu
Undecided
Unassigned

Bug Description

This is a general problem, but I'll mention the parts where it's causing me pain. I wrote a launchpadlib class that can act as a trusted client, the equivalent of the user's web browser. Because it's not a web browser and no one's looking at the HTML, I need to set the status codes properly to convey different error conditions. Here's the code I have:

1. A GET request that asks for a media type of application/json.
1A. If the response status is 200 and the Location header contains the string "+login", the response status should actually be 401.
1B. Otherwise, if the media type is not application/json, I assume there has been a server-side error and I change the status code to 500.

2. A POST request to authorize an OAuth request token.
2A. If the response entity-body contains the string "Unauthenticated user POSTing to page", the response status should actually be 401.
2B. If the entity-body contains the string "Request already reviewed", the token has already been authorized and the response status should actually be 209.
2C. If the entity-body contains the string "Unable to identify application", there is a client-side error and the response status should actually be 400.
2D. If the entity-body contains the string "What level of access", the token has not been successfully authorized, and the response status should actually be 400.
2E. Otherwise, if the entity-body does not contain the string "Almost finished", I assume there has been a server-side error and change the status code to 500.

Except for 1B and 2E, there's no reason why these operations shouldn't return the proper response code. This will make launchpadlib much more robust: right now the simulated browser can break because of trivial wording changes to Launchpad.

Changed in ubuntu:
status: New → Invalid
Gary Poster (gary) wrote :

Marking as oauth, even though the scope is bigger, because much of the specific bits are related.

Changed in launchpad-foundations:
status: New → Triaged
importance: Undecided → Low
tags: added: openid
tags: added: oauth
removed: openid
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers