Redirecting to a 200 response offline.html is a really bad idea for the API
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Launchpad itself |
Triaged
|
Low
|
Unassigned | ||
lazr.restful |
Triaged
|
Low
|
Unassigned |
Bug Description
Hi,
Using the API I sometimes see
File "/usr/lib/
return super(Entry, self)._
File "/usr/lib/
return self.lp_
File "/usr/lib/
self.
File "/usr/lib/
representation, self.JSON_
File "/usr/lib/
representat
File "/usr/lib/
self.
File "/var/lib/
return _default_
File "/var/lib/
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/var/lib/
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
Catching it in the act shows that it is actually sending
send: 'GET /beta/ubuntu/lucid HTTP/1.1\r\nHost: api.edge.
reply: 'HTTP/1.1 302 Found\r\n'
header: Date: Thu, 07 Jan 2010 11:01:03 GMT
header: Cache-Control: no-cache
header: Location: /offline.html
header: Via: 1.1 wildcard.
header: Transfer-Encoding: chunked
header: Content-Type: text/plain
send: 'GET /offline.html HTTP/1.1\r\nHost: api.edge.
reply: 'HTTP/1.1 200 OK\r\n'
header: Date: Thu, 07 Jan 2010 11:01:53 GMT
header: Server: Apache/2.2.8 (Ubuntu) mod_ssl/2.2.8 OpenSSL/0.9.8g
header: Last-Modified: Mon, 22 Jun 2009 09:40:43 GMT
header: ETag: "1946dd-
header: Accept-Ranges: bytes
header: Content-Length: 921
header: Content-Type: text/html
so launchpadlib dutifully tries to decode
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
as a representation of Ubuntu Lucid, which isn't going to work very well.
When LP is offline could you please not redirect webservice requests to offline.html?
I would suggest returning a 503 with the same contents in the body, or just making
offline.html return 503 (this would make sense for browser users too no?)
Thanks,
James
Related branches
- Francis J. Lacoste (community): Needs Resubmitting
- Graham Binns (community): Approve (code)
-
Diff: 88 lines (+38/-9)2 files modifiedsrc/lazr/restfulclient/errors.py (+15/-0)
src/lazr/restfulclient/resource.py (+23/-9)
affects: | launchpad → launchpad-foundations |
Changed in launchpad-foundations: | |
importance: | Undecided → Low |
status: | New → Triaged |
Changed in lazr.restful: | |
importance: | Undecided → Low |
status: | New → Triaged |
Adding a lazr.restful task as trying to decode a Content-Type: text/html response
as JSON probably isn't the best thing to do. If it doesn't have a wadl representation
corresponding to that content type it should probably just throw an error that says
that. It would at least have made this problem easier to debug.
Thanks,
James