My favorites | Sign in
Project Home Downloads Wiki Issues Source
New issue   Search
for
  Advanced search   Search tips   Subscriptions
Issue 2764: 500 Server Error when using the set review REST api with inline comments
2 people starred this issue and may be notified of changes. Back to list
Status:  Invalid
Owner:  ----
Closed:  Jul 2014


Sign in to add a comment
 
Project Member Reported by zaro0508, Jul 8, 2014
Affected Version: master

What steps will reproduce the problem?
1. setup gerrit.  I setup a clean gerrit site.
2. create an admin user
3. add a change to gerrit.  I created a change with one file "pike.txt" that contains 1 line of text.
4. use the admin user to post a review to the change using the set review REST API.

~/temp$ cat my-review.txt
{
  "message": "Some nits need to be fixed.",
  "labels": {
    "Code-Review": -1
  },
  "comments": {
    "pike.txt": [
      {
        "line": 1,
        "message": "[nit] trailing whitespace"
      },
    ]
  }
}

~/temp$ curl -v -n -X POST --digest --user 'zaro:XXXXXX' --data-binary @my-review.txt --header "Content-Type: application/json;charset=UTF-8" http://localhost:8080/a/changes/2/revisions/1/review

What is the expected output?
I expect info from my-review.txt to post to the change.  

What do you see instead?
I get a 500 Server Error response.

Please provide any additional information below.
If I remove the inline comment section for pike.txt from my-review.txt the POST works without error.  I got the json from the example in the REST api documentation: https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#set-review
Jul 8, 2014
Project Member #1 zaro0508
(No comment was entered for this change.)
curl.log
2.6 KB   View   Download
Jul 9, 2014
Project Member #2 David.Os...@gmail.com
Can you pastebin server log?
Status: Accepted
Jul 9, 2014
Project Member #3 David.Os...@gmail.com
I've checked it on stable-2.8. Works as expected.
Jul 9, 2014
Project Member #4 zaro0508
I have not tried on 2.8 but it definitely repros on master.  Attached is the server log..

[2014-07-09 09:28:05,235] ERROR com.google.gerrit.httpd.restapi.RestApiServlet : Error in POST /a/changes/1/revisions/1/review
java.lang.NullPointerException
	at com.google.gerrit.server.change.PostReview.checkComments(PostReview.java:305)
	at com.google.gerrit.server.change.PostReview.apply(PostReview.java:133)
	at com.google.gerrit.server.change.PostReview.apply(PostReview.java:74)
	at com.google.gerrit.httpd.restapi.RestApiServlet.service(RestApiServlet.java:304)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
server.log
9.2 KB   View   Download
Jul 9, 2014
Project Member #5 zaro0508
(No comment was entered for this change.)
Labels: -Priority-Minor Priority-Major
Jul 10, 2014
Project Member #6 David.Os...@gmail.com
It turns out, your JSON example is invalid. And it is not as specified in rest-api-changes files:

  {
    "message": "Some nits need to be fixed.",
    "labels": {
      "Code-Review": -1
    },
    "comments": {
      "gerrit-server/src/main/java/com/google/gerrit/server/project/RefControl.java": [
        {
          "line": 23,
          "message": "[nit] trailing whitespace"
        },
        {
          "line": 49,
          "message": "[nit] s/conrtol/control"
        }
      ]
    }
  }

So you have removed the second CommentInput entity from the roginal example,
but erroneously preserved the comma. JSON parses still things that there are
two CommentInput elements in the array and put null as second element:

  [CommentInput, null]

Remove the comma, or add second CommentInput element to the list and it would work.

Status: Invalid
Sign in to add a comment

Powered by Google Project Hosting