Fix NPE in QueryResource on bad query