Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
Trac
Trac
  • Project overview
    • Project overview
    • Details
    • Activity
  • Issues 246
    • Issues 246
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Operations
    • Operations
    • Metrics
    • Incidents
  • Analytics
    • Analytics
    • Value Stream
  • Wiki
    • Wiki
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Create a new issue
  • Issue Boards

GitLab is used only for code review, issue tracking and project management. Canonical locations for source code are still https://gitweb.torproject.org/ https://git.torproject.org/ and git-rw.torproject.org.

  • Legacy
  • TracTrac
  • Issues
  • #21036

Closed (moved)
Open
Opened Dec 20, 2016 by Trac@tracbot

Onionoo doesn't return JSON for error responses

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.

Trac:
Username: lukechilds

To upload designs, you'll need to enable LFS and have admin enable hashed storage. More information
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: legacy/trac#21036