Fix: Wrong error message was added when the query was invalid