fixes error when retrieving a non-existant query
Merge pull request #892 from opf/fix/invalid_query_retrieval