Fixed query link generation and error reporting