Detect invalid query