[metrics-bugs] #21036 [Metrics/Onionoo]: Onionoo doesn't return JSON for error responses

Tor Bug Tracker & Wiki blackhole at torproject.org
Tue Dec 20 04:58:08 UTC 2016


#21036: Onionoo doesn't return JSON for error responses
---------------------------------+--------------------------
     Reporter:  lukechilds       |      Owner:  metrics-team
         Type:  defect           |     Status:  new
     Priority:  Low              |  Milestone:
    Component:  Metrics/Onionoo  |    Version:
     Severity:  Minor            |   Keywords:
Actual Points:                   |  Parent ID:
       Points:                   |   Reviewer:
      Sponsor:                   |
---------------------------------+--------------------------
 From the Onionoo docs:

 > Onionoo clients send HTTP GET requests to the Onionoo server which
 responds with JSON-formatted replies.

 > Clients should be able to handle all valid JSON responses

 https://onionoo.torproject.org/protocol.html#general

 However Onionoo only returns JSON on a successful response, errors are
 returned in HMTL. For example:

 Returns JSON:
 https://onionoo.torproject.org/summary?limit=1

 Returns HTML:
 https://onionoo.torproject.org/summary?limit=foo

 The HTTP lib I'm using in my Onionoo client library is configured for JSON
 so it automatically parses the response for me. This means when I get an
 error (400 Bad Request in the above example) I don't get a chance to throw
 a useful bad request request error as the HTTP lib has already thrown a
 parse error.

 I've implemented a fix by configuring my HTTP lib for text responses and
 then manually parsing the JSON myself, only for successful responses. This
 obviously isn't a major issue but I think it would be better (and match
 the spec) if Onionoo returned errors formatted as JSON. If that's going to
 be an issue it should mention that errors are returned as HTML in the
 spec.

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/21036>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the metrics-bugs mailing list