Error attempting to authenticate

73 views
Skip to first unread message

joda_man

unread,
Dec 22, 2010, 2:58:25 PM12/22/10
to Repo and Gerrit Discussion
Hi,
I'm trying to create a tool to automatically comment on reviews,
attempting to use the JSON interface (I believe that's my only real
option as of now, right?). I'm having troubles logging in. The
(pruned) stack trace from my gerrit error_log is:

[2010-12-22 11:37:53,613] WARN org.eclipse.jetty.util.log : /gerrit/
rpc/UserPassAuthService
java.lang.IllegalArgumentException: condition failed: false
at com.google.gson.Preconditions.checkArgument(Preconditions.java:39)
at com.google.gson.JsonObject.add(JsonObject.java:55)
at com.google.gwtjsonrpc.server.JsonServlet
$2.serialize(JsonServlet.java:542)
at com.google.gwtjsonrpc.server.JsonServlet
$2.serialize(JsonServlet.java:531)
at
com.google.gson.JsonSerializationVisitor.findAndInvokeCustomSerializer(JsonSerializationVisitor.java:
186)
at
com.google.gson.JsonSerializationVisitor.visitUsingCustomHandler(JsonSerializationVisitor.java:
161)
at com.google.gson.ObjectNavigator.accept(ObjectNavigator.java:98)
at
com.google.gson.JsonSerializationContextDefault.serialize(JsonSerializationContextDefault.java:
56)
at com.google.gson.Gson.toJsonTree(Gson.java:230)
at com.google.gson.Gson.toJson(Gson.java:315)
at com.google.gson.Gson.toJson(Gson.java:290)
at
com.google.gwtjsonrpc.server.JsonServlet.formatResult(JsonServlet.java:
574)
at com.google.gwtjsonrpc.server.JsonServlet.service(JsonServlet.java:
278)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

The script is a groovy script using the HttpBuilder class. A
pertinent snippet of its log output is:
DEBUG headers - >> POST /gerrit/rpc/UserPassAuthService HTTP/1.1
DEBUG headers - >> Content-Type: application/json
DEBUG headers - >> Host: <myHost>
DEBUG wire - >> "{"jsonrpc":"2.0","method":"authenticate","params":
["myUser","myPass"],"id":1}"
DEBUG wire - << "HTTP/1.1 500 condition failed: false[EOL]"

I compared the JSON I'm sending to what I saw in firebug and it looks
right to me (I hardcoded the "id" to 1 - I don't think that's the
problem though).

Any thoughts? Am I completely off-base in what I'm trying to do?

Any logging I can enable server-side?

Thanks,
Jeremy

Martin Fick

unread,
Dec 22, 2010, 3:08:05 PM12/22/10
to repo-d...@googlegroups.com, joda_man
On Wednesday 22 December 2010 12:58:25 pm joda_man wrote:
> Hi,
> I'm trying to create a tool to automatically comment on
> reviews, attempting to use the JSON interface (I believe
> that's my only real option as of now, right?).


You should likely be able to use the ssh review command
instead.

-Martin

joda_man

unread,
Dec 22, 2010, 3:21:36 PM12/22/10
to Repo and Gerrit Discussion
I'm sorry I wasn't specific enough. I want to add comments to files
within a patch set, not just review-level comments. I don't believe
the ssh review command supports that level of commenting.

Thanks,
Jeremy
Jeremy

Shawn Pearce

unread,
Dec 22, 2010, 3:29:31 PM12/22/10
to joda_man, Repo and Gerrit Discussion
On Wed, Dec 22, 2010 at 11:58, joda_man <schm...@yahoo.com> wrote:
>  I'm trying to create a tool to automatically comment on reviews,
> attempting to use the JSON interface (I believe that's my only real
> option as of now, right?).  I'm having troubles logging in.  The
> (pruned) stack trace from my gerrit error_log is:
>
> [2010-12-22 11:37:53,613] WARN  org.eclipse.jetty.util.log : /gerrit/
> rpc/UserPassAuthService
> java.lang.IllegalArgumentException: condition failed: false
...
> com.google.gwtjsonrpc.server.JsonServlet.formatResult(JsonServlet.java:
> 574)

Ugh. Gson doesn't like the JSON object tree the server built as a
response to your call. That probably means you tripped an error path
with your request, and that particular error path is apparently not
well tested.

>   DEBUG  headers - >> POST /gerrit/rpc/UserPassAuthService HTTP/1.1
>   DEBUG  headers - >> Content-Type: application/json
>   DEBUG  headers - >> Host: <myHost>
>   DEBUG  wire - >> "{"jsonrpc":"2.0","method":"authenticate","params":
> ["myUser","myPass"],"id":1}"
>   DEBUG  wire - << "HTTP/1.1 500 condition failed: false[EOL]"

The request almost seems correct. Have you tried also setting
Content-Length and adding "; charset=UTF-8" to the Content-Type
header?

Content-Length: 73
Content-Type: application/json; charset=UTF-8

{"jsonrpc":"2.0","method":"authenticate","params":["test","user"],"id":3}

> I compared the JSON I'm sending to what I saw in firebug and it looks
> right to me (I hardcoded the "id" to 1 - I don't think that's the
> problem though).

Yea, the id doesn't really matter here. Its just a sequential counter
from the web UI.

Shawn Pearce

unread,
Dec 22, 2010, 3:30:06 PM12/22/10
to joda_man, Repo and Gerrit Discussion
On Wed, Dec 22, 2010 at 12:21, joda_man <schm...@yahoo.com> wrote:
> On Dec 22, 3:08 pm, Martin Fick <mf...@codeaurora.org> wrote:
>>
>> You should likely be able to use the ssh review command
>> instead.
>>
> I'm sorry I wasn't specific enough.  I want to add comments to files
> within a patch set, not just review-level comments.  I don't believe
> the ssh review command supports that level of commenting.

You are right, the ssh review command doesn't (yet) support commenting
on files within a patch set. Missing feature. :-\

joda_man

unread,
Dec 22, 2010, 4:59:46 PM12/22/10
to Repo and Gerrit Discussion


On Dec 22, 3:29 pm, Shawn Pearce <s...@google.com> wrote:
> On Wed, Dec 22, 2010 at 11:58, joda_man <schme...@yahoo.com> wrote:

> >   DEBUG  headers - >> Content-Type: application/json
> >   DEBUG  headers - >> Host: <myHost>
> >   DEBUG  wire - >> "{"jsonrpc":"2.0","method":"authenticate","params":
> > ["myUser","myPass"],"id":1}"
> >   DEBUG  wire - << "HTTP/1.1 500 condition failed: false[EOL]"
>
> The request almost seems correct.  Have you tried also setting
> Content-Length and adding "; charset=UTF-8" to the Content-Type
> header?

The missing "; charset=UTF-8" was indeed the problem. I should have
noticed that before posting. Thanks for your quick help!

Jeremy
Reply all
Reply to author
Forward
0 new messages