Andrew Maddison


Cube and Jersey Dropwizard SyntaxError: Unexpected Token /u001f

We’re experimenting with Cube which is a tool that aggregates and indexes a bunch of events, and allows you to query them to produce live dashboards etc. It’s written in javascript, and runs on node with a MongoDb back end.

We’re calling it from a Dropwizard java service, which used Jersey’s client under the hood, but when we posted an event into Cube, we got a slightly weird error, a 400 (bad request) with the following message:

SyntaxError: Unexpected token \u001f


add the following to the httpClient section of your Dropwizard config,

gzipEnabledForRequests: false

Long version:

What seems to happen is that Jersey’s client gzip encodes all requests by default, (and duly sets the Content-Encoding header to gzip).

We used Charles Proxy to look at the request – and noticed that the first character of the compressed request is “1f” in hex, which happens to be the hex representation of the offending unicode character “\u001f” (which is an obscure non-printing control character, and a big fat red herring.)

So either Cube, or node or something is unable to accept gzip encoded requests, and barfs out a bad request.