Page MenuHomePhabricator

Format error in Gerrit API response - First line starts with: )]}'
Closed, DuplicatePublic

Description

Seems like all response from the Gerrit API starts with a line with the content:

)]}'

For example, https://gerrit.wikimedia.org/r/changes/I56f5c03fea40af3ee4ec50f258516d0833625c6e returns:

)]}'
{
  "id": "labs%2Ftools%2FIsa~master~I56f5c03fea40af3ee4ec50f258516d0833625c6e",
  "project": "labs/tools/Isa",
  "branch": "master",
  "topic": "daily-contrib-graph",
  "hashtags": [],
...

Another example, https://gerrit.wikimedia.org/r/accounts/689 returns:

)]}'
{
  "_account_id": 689,
  "name": "Gabrielchihonglee",
  "email": "chihonglee777@gmail.com",
  "username": "gabrielchihonglee"
}

Event Timeline

hashar subscribed.

You have to strip the first line from the response which is inserted for security reason. Some details at https://gerrit.wikimedia.org/r/Documentation/rest-api.html#output

Oh sorry about that. Thanks for telling me that.

Aklapper renamed this task from Format error in Gerrit API response to Format error in Gerrit API response - First line starts with: )]}'.Aug 21 2020, 8:25 AM

No worries! To be fair it is a bit annoying and I imagine everyone that tries querying the API had the exact same question :]