Fix NPE in QueryResource on bad query

ideally a bad query would return 400 Bad Request to indicate client error.